Re: [PATCH] D19815: Support '#pragma once' in headers when using PCH

2016-05-13 Thread Warren Ristow via cfe-commits
wristow added a comment.

In http://reviews.llvm.org/D19815#428705, @rsmith wrote:

> Rather than threading through a new flag, can you test the existing `TUKind` 
> field?


Yes, that does seem to do the trick.  I'll do some testing on it, but with that 
approach, it should be a simple one-line change.  Thanks.


http://reviews.llvm.org/D19815



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


Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

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


Comment at: clang-rename/USRLocFinder.cpp:37
@@ -35,3 +36,3 @@
 public:
-  explicit USRLocFindingASTVisitor(const std::string USR) : USR(USR) {
+  explicit USRLocFindingASTVisitor(const std::string USR, const std::string 
&PrevName) : USR(USR), PrevName(PrevName) {
   }

For constructors, we nowadays usually want to take strings by value and then 
std::move them into the fields.


Comment at: clang-rename/USRLocFinder.cpp:75
@@ +74,3 @@
+  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Range), 
Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName.startswith(PrevName)) {
+// The token of the source location we find actually has the old 
name.

Why startswith as opposed to ==?


Comment at: clang-rename/USRLocFinder.h:30-33
@@ -29,5 +29,6 @@
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
 std::vector getLocationsOfUSR(const std::string usr,
+  const std::string &PrevName,
   Decl *decl);
 }
 }

Now that I see this - is there a reason not to use const std::string& for the 
usr? Also, should we instead use StringRef?


http://reviews.llvm.org/D20216



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


Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

2016-05-13 Thread Miklos Vajna via cfe-commits
vmiklos added inline comments.


Comment at: clang-rename/USRLocFinder.cpp:75
@@ +74,3 @@
+  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Range), 
Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName.startswith(PrevName)) {
+// The token of the source location we find actually has the old 
name.

klimek wrote:
> Why startswith as opposed to ==?
The source range is "foo(0)", the old name is "foo". Or is there a way to get 
the range of the name part of the initializer, without the "(0)" part?

I'll fix the rest, those are easy. :-)


http://reviews.llvm.org/D20216



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


Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

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


Comment at: clang-rename/USRLocFinder.cpp:75
@@ +74,3 @@
+  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Range), 
Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName.startswith(PrevName)) {
+// The token of the source location we find actually has the old 
name.

vmiklos wrote:
> klimek wrote:
> > Why startswith as opposed to ==?
> The source range is "foo(0)", the old name is "foo". Or is there a way to get 
> the range of the name part of the initializer, without the "(0)" part?
> 
> I'll fix the rest, those are easy. :-)
Yep, if you want to get an identifier, you just get the code for the range 
getLocation(), getLocation() (note that ranges are inclusive token-ranges by 
default)


http://reviews.llvm.org/D20216



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


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

2016-05-13 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57138.
mprobst added a comment.

- extract TokenAnalyzer.h and SortJavaScriptImports.h/cpp
- clean up imports/
- includes
- address review comments
- pull out implementations from header files.
- support side effect imports, keep in relative order at top.


http://reviews.llvm.org/D20198

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

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,137 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, StringRef FileName = "input.js") {
+auto Ranges = GetCodeRange(Code);
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code) {
+std::string Result = sort(Code);
+EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 'apath';\n"
+ "export {P} from '../parent';\n"
+ "export {R} from './relative';\n"
+ "export {S};\n"
+ "\n"
+ "let x = 1;\n"
+ "export y = 1;\n",
+ "export {R} from './relative';\n"
+ "import {T} from './cpath';\n"
+ "export {S};\n"
+ "export {A, B} from 'apath';\n"
+ "import

Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-05-13 Thread Manuel Klimek via cfe-commits
klimek added a comment.

We had problems with binary size in multiple places.
Overall, I think if we care about binary size we should try to make binary size 
smaller at a higher level (perhaps by hiding visibility of symbols by default; 
not sure how much that would affect the exe's though).

Until we have a better solution for binary size, I'd add a FIXME and accept 
possible false positives / false negatives until we get more bug reports.


http://reviews.llvm.org/D17981



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


Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

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

Got rid of startswith() and now using StringRef everywhere instead of a mix of 
std::string, const std::string and const std::string&.


http://reviews.llvm.org/D20216

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h

Index: clang-rename/USRLocFinder.h
===
--- clang-rename/USRLocFinder.h
+++ clang-rename/USRLocFinder.h
@@ -19,15 +19,18 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringRef.h"
+
 namespace clang {
 
 class Decl;
 class SourceLocation;
 
 namespace rename {
 
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
-std::vector getLocationsOfUSR(const std::string usr,
+std::vector getLocationsOfUSR(llvm::StringRef usr,
+  llvm::StringRef PrevName,
   Decl *decl);
 }
 }
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Index/USRGeneration.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 
 using namespace llvm;
@@ -33,7 +34,7 @@
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(const std::string USR) : USR(USR) {
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) {
   }
 
   // Declaration visitors:
@@ -58,6 +59,7 @@
   }
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+const ASTContext &Context = ConstructorDecl->getASTContext();
 for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
   const clang::CXXCtorInitializer* Initializer = *it;
   if (Initializer->getSourceOrder() == -1) {
@@ -68,7 +70,12 @@
   if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
-  LocationsFound.push_back(Initializer->getSourceLocation());
+  SourceLocation Location = Initializer->getSourceLocation();
+  StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName == PrevName) {
+// The token of the source location we find actually has the old name.
+LocationsFound.push_back(Initializer->getSourceLocation());
+  }
 }
   }
 }
@@ -116,14 +123,17 @@
   }
 
   // All the locations of the USR were found.
-  const std::string USR;
+  StringRef USR;
+  // Old name that is renamed.
+  StringRef PrevName;
   std::vector LocationsFound;
 };
 } // namespace
 
-std::vector getLocationsOfUSR(const std::string USR,
+std::vector getLocationsOfUSR(StringRef USR,
+  StringRef PrevName,
   Decl *Decl) {
-  USRLocFindingASTVisitor visitor(USR);
+  USRLocFindingASTVisitor visitor(USR, PrevName);
 
   visitor.TraverseDecl(Decl);
   return visitor.getLocationsFound();
Index: clang-rename/RenamingAction.cpp
===
--- clang-rename/RenamingAction.cpp
+++ clang-rename/RenamingAction.cpp
@@ -49,7 +49,7 @@
 std::vector NewCandidates;
 
 for (const auto &USR : USRs) {
-  NewCandidates = getLocationsOfUSR(USR, Context.getTranslationUnitDecl());
+  NewCandidates = getLocationsOfUSR(USR, PrevName, Context.getTranslationUnitDecl());
   RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(),
 NewCandidates.end());
   NewCandidates.clear();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-13 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1822
@@ +1821,3 @@
+cleanupRight(Line->First, Line->Last, tok::comma, tok::comma);
+checkConstructorInitList(*Line);
+  }

djasper wrote:
> You could turn this into:
> 
> for (auto &Line : AnnotatedLines) {
>   if (Line->Affected) {
> cleanupRight(Line->First, tok::comma, tok::comma);
> cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
> cleanupLeft(Line->First, tok::comma, tok::l_brace);
> cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
>   }
> }
Wouldn't `cleanupLeft(Line->First, tok::comma, tok::l_brace);` also remove the 
comma from  `std::vector> = {{...}, {...}}`?


http://reviews.llvm.org/D19804



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


Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

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

lg



Comment at: clang-rename/USRLocFinder.cpp:126-128
@@ -118,3 +125,5 @@
   // All the locations of the USR were found.
-  const std::string USR;
+  StringRef USR;
+  // Old name that is renamed.
+  StringRef PrevName;
   std::vector LocationsFound;

Usually storing StringRefs in the class is dangerous, but as this is defined in 
the .cpp file and only used as part of the function, that's probably fine.
(I personally would still make them std::string members, and copy either in the 
constructor or when passing into the function).


http://reviews.llvm.org/D20216



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


Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-13 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1822
@@ +1821,3 @@
+cleanupRight(Line->First, Line->Last, tok::comma, tok::comma);
+checkConstructorInitList(*Line);
+  }

ioeric wrote:
> djasper wrote:
> > You could turn this into:
> > 
> > for (auto &Line : AnnotatedLines) {
> >   if (Line->Affected) {
> > cleanupRight(Line->First, tok::comma, tok::comma);
> > cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
> > cleanupLeft(Line->First, tok::comma, tok::l_brace);
> > cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
> >   }
> > }
> Wouldn't `cleanupLeft(Line->First, tok::comma, tok::l_brace);` also remove 
> the comma from  `std::vector> = {{...}, {...}}`?
I should've added this case into unit test, sorry...

But I think we can either handle constructor initializer's tok::l_brace 
specially or annotate it? The later solution can enable us to do 
`cleanupLeft(Line->First, tok::comma, TT_CtorInitializerLBrace);`.


http://reviews.llvm.org/D19804



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


r269400 - [ms][dll] #27212: Generating of implicit special members should take into account MSVC compatibility version

2016-05-13 Thread Dmitry Polukhin via cfe-commits
Author: dpolukhin
Date: Fri May 13 04:03:56 2016
New Revision: 269400

URL: http://llvm.org/viewvc/llvm-project?rev=269400&view=rev
Log:
[ms][dll] #27212: Generating of implicit special members should take into 
account MSVC compatibility version

Clang creates implicit move constructor/assign operator in all cases if
there is std=c++11. But MSVC supports such generation starting from
version 1900 only. As result we have some binary incompatibility.

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

Patch by Andrew V. Tischenko

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=269400&r1=269399&r2=269400&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri May 13 04:03:56 2016
@@ -4774,7 +4774,6 @@ void Sema::checkClassLevelDLLAttribute(C
 
   // The class is either imported or exported.
   const bool ClassExported = ClassAttr->getKind() == attr::DLLExport;
-  const bool ClassImported = !ClassExported;
 
   TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind();
 
@@ -4809,9 +4808,12 @@ void Sema::checkClassLevelDLLAttribute(C
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
   continue;
 
-// MSVC versions before 2015 don't export the move assignment 
operators,
-// so don't attempt to import them if we have a definition.
-if (ClassImported && MD->isMoveAssignmentOperator() &&
+// MSVC versions before 2015 don't export the move assignment operators
+// and move constructor, so don't attempt to import/export them if
+// we have a definition.
+auto *CXXC = dyn_cast(MD);
+if ((MD->isMoveAssignmentOperator() ||
+ (CXXC && CXXC->isMoveConstructor())) &&
 !getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2015))
   continue;
   }

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=269400&r1=269399&r2=269400&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Fri May 13 04:03:56 2016
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w | FileCheck --check-prefix=MSC 
--check-prefix=M32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck 
--check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck 
--check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 %s
+
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w 
-fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC 
--check-prefix=M64 -check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w 
-fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC 
--check-prefix=M64 -check-prefix=MSVC2013 %s
+
 // RUN: %clang_cc1 -triple i686-windows-gnu-emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=GNU --check-prefix=G64 %s
 
@@ -528,6 +532,8 @@ struct SomeTemplate {
   SomeTemplate(T o = T()) : o(o) {}
   T o;
 };
+// MSVC2015-DAG: define weak_odr dllexport {{.+}} 
@"\01??4?$SomeTemplate@H@@Q{{.+}}@$$Q{{.+}}@@Z"
+// MSVC2013-DAG: define weak_odr dllexport {{.+}} 
@"\01??4?$SomeTemplate@H@@Q{{.+}}0@A{{.+}}0@@Z"
 struct __declspec(dllexport) InheritFromTemplate : SomeTemplate {};
 
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01??_F?$SomeTemplate@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
@@ -616,7 +622,8 @@ struct __declspec(dllexport) X : public
 
 struct __declspec(dllexport) Y {
   // Move assignment operator:
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc 
dereferenceable({{[0-9]+}}) %stru

Re: [PATCH] D19156: [ms][dll] #27212: Generating of implicit special members should take into account MSVC compatibility version

2016-05-13 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin closed this revision.
DmitryPolukhin added a comment.

Committed as http://reviews.llvm.org/rL269400


http://reviews.llvm.org/D19156



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


Re: [PATCH] D20205: [include-fixer] Use scope contexts information to improve query.

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

Improvement and use unittest.


http://reviews.llvm.org/D20205

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/XrefsDBManager.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -52,6 +52,7 @@
   {"std::sting", {"\"sting\""}},
   {"std::string::size_type", {""}},
   {"a::b::foo", {"dir/otherdir/qux.h"}},
+  {"a::b::bar", {"\"bar.h\""}},
   };
   auto XrefsDBMgr = llvm::make_unique();
   XrefsDBMgr->addXrefsDB(
@@ -129,6 +130,20 @@
 runIncludeFixer("std::string bar;\nstd::sting foo;\n"));
 }
 
+TEST(IncludeFixer, ScopedNamespaceSymbols) {
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { b::bar b; }\n",
+runIncludeFixer("namespace a { b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { a::b::bar b; }\n",
+runIncludeFixer("namespace A { a::b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { void func() { b::bar b; } }\n",
+runIncludeFixer("namespace a { void func() { b::bar b; } }\n"));
+  EXPECT_EQ("namespace A { c::b::bar b; }\n",
+runIncludeFixer("namespace A { c::b::bar b; }\n"));
+  // FIXME: The header should not be added here. Remove this after we support
+  // full match.
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
+runIncludeFixer("namespace A { b::bar b; }\n"));
+}
 } // namespace
 } // namespace include_fixer
 } // namespace clang
Index: include-fixer/XrefsDBManager.cpp
===
--- include-fixer/XrefsDBManager.cpp
+++ include-fixer/XrefsDBManager.cpp
@@ -39,18 +39,20 @@
 if (Symbol.getName() == Names.back()) {
   bool IsMatched = true;
   auto SymbolContext = Symbol.getContexts().begin();
+  auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend() &&
-   SymbolContext != Symbol.getContexts().end();
+  for (; IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end();
++IdentiferContext, ++SymbolContext) {
 if (SymbolContext->second != *IdentiferContext) {
   IsMatched = false;
   break;
 }
   }
 
-  if (IsMatched) {
+  // FIXME: Support full match. At this point, we only find symbols in
+  // database which end with the same contexts with the identifier.
+  if (IsMatched && IdentiferContext == Names.rend()) {
 // FIXME: file path should never be in the form of <...> or "...", but
 // the unit test with fixed database use <...> file path, which might
 // need to be changed.
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -115,6 +115,19 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+std::string TypoScopeString;
+if (S) {
+  // FIXME: Currently we only use namespace contexts. Use other context
+  // types for query.
+  for (const auto *Context = S->getEntity(); Context;
+   Context = Context->getParent()) {
+if (const auto *ND = dyn_cast(Context)) {
+  if (!ND->getName().empty())
+TypoScopeString = ND->getNameAsString() + "::" + TypoScopeString;
+}
+  }
+}
+
 /// If we have a scope specification, use that to get more precise results.
 std::string QueryString;
 if (SS && SS->getRange().isValid()) {
@@ -149,7 +162,23 @@
   QueryString = Typo.getAsString();
 }
 
-return query(QueryString, Typo.getLoc());
+// Follow C++ Lookup rules. Firstly, lookup the identifier with scoped
+// namespace contexts. If fails, falls back to identifier.
+// For example:
+//
+// namespace a {
+// b::foo f;
+// }
+//
+// 1. lookup a::b::foo.
+// 2. lookup b::foo.
+if (!query(TypoScopeString + QueryString, Typo.getLoc()))
+  query(QueryString, Typo.getLoc());
+
+// FIXME: We should just return the name we got as input here and prevent
+// clang from trying to correct the typo by itself. That may change the
+// identifier to something that's not wanted by the user.
+return clang::TypoCorrection();
   }
 
   StringRef filename() const { return Filename; }
@@ -234,12 +263,12 @@
 
 private:
   /// Query the database for a given identifier.
-  clang::TypoCorrection query(StringRef Query, SourceLocation Loc) {
+  bool query(StringRef Query, SourceLocation Loc) {
 assert(!Query.empty() && "Empty quer

Re: [PATCH] D20203: [find-all-symbols] Add enum type support.

2016-05-13 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269401: [find-all-symbols] Add enum type support. (authored 
by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20203?vs=57021&id=57143#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20203

Files:
  clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  
clang-tools-extra/trunk/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
@@ -104,17 +104,19 @@
   })";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol =
-  CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
+  SymbolInfo Symbol = CreateSymbolInfo(
+  "xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
-{{SymbolInfo::Namespace, "na"}});
+  Symbol =
+  CreateSymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
+   {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo(
-  "", SymbolInfo::Variable, HeaderName, 5,
-  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
+  Symbol =
+  CreateSymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5,
+   {{SymbolInfo::ContextType::Namespace, "nb"},
+{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -128,11 +130,12 @@
   })";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol =
-  CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
+  SymbolInfo Symbol = CreateSymbolInfo(
+  "C_Func", SymbolInfo::SymbolKind::Function, HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
+  Symbol = CreateSymbolInfo("C_struct", SymbolInfo::SymbolKind::Class,
+HeaderName, 4, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -152,13 +155,18 @@
   )";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol =
-  CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
+  SymbolInfo Symbol = CreateSymbolInfo("Glob", SymbolInfo::SymbolKind::Class,
+   HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
-{{SymbolInfo::Namespace, "na"}});
+  Symbol = CreateSymbolInfo("A", SymbolInfo::SymbolKind::Class, HeaderName, 6,
+{{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = CreateSymbolInfo("AAA", SymbolInfo::SymbolKind::Class, HeaderName, 7,
+{{SymbolInfo::ContextType::Record, "A"},
+ {SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_FALSE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbolsTemplate) {
@@ -179,8 +187,8 @@
   )";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol =
-  CreateSymbolInfo("T_TEMP", SymbolInfo::Class, HeaderName, 3, {});
+  SymbolInfo Symbol = CreateSymbolInfo("T_TEMP", SymbolInfo::SymbolKind::Class,
+   HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -200,21 +208,23 @@
   )";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol = CreateSymbolInfo("gg", SymbolInfo::Function, HeaderName,
-   3, {{SymbolInfo::Namespace, "na"}});
+  SymbolInfo Symbol =
+  CreateSymbolInfo("gg", SymbolInfo::SymbolKind::Function, HeaderName, 3,
+   {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("f", SymbolInfo::Function, HeaderName, 4,
-{{SymbolInfo::Namespace, "na"}});
+  Symbol = CreateSymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName,
+4, {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("SSSFFF", SymbolInfo::Function, HeaderName, 5,
-{{SymbolInfo::Namespace, "na"}});
+  Symbol =
+  CreateSymbolInfo("SSSFFF", SymbolInfo::SymbolKind::Function, HeaderName,
+   5, {{

[clang-tools-extra] r269401 - [find-all-symbols] Add enum type support.

2016-05-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 13 04:15:37 2016
New Revision: 269401

URL: http://llvm.org/viewvc/llvm-project?rev=269401&view=rev
Log:
[find-all-symbols] Add enum type support.

Summary:
Also change enums defined in SymbolInfo to scoped enums to avoid
conflicts.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

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

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

Modified: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp?rev=269401&r1=269400&r2=269401&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp Fri May 13 
04:15:37 2016
@@ -28,7 +28,8 @@ InMemoryXrefsDB::InMemoryXrefsDB(
   *IdentiferContext);
   }
 
-  SymbolInfo Symbol(Names.back(), SymbolInfo::Class, Header, Contexts, 1);
+  SymbolInfo Symbol(Names.back(), SymbolInfo::SymbolKind::Class, Header,
+Contexts, 1);
   this->LookupTable[Symbol.getName()].push_back(Symbol);
 }
   }

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=269401&r1=269400&r2=269401&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 13 04:15:37 2016
@@ -23,6 +23,13 @@ using namespace clang::ast_matchers;
 namespace clang {
 namespace find_all_symbols {
 namespace {
+
+AST_MATCHER(EnumConstantDecl, isInScopedEnum) {
+  if (const auto *ED = dyn_cast(Node.getDeclContext()))
+return ED->isScoped();
+  return false;
+}
+
 std::vector GetContexts(const NamedDecl *ND) {
   std::vector Contexts;
   for (const auto *Context = ND->getDeclContext(); Context;
@@ -34,12 +41,16 @@ std::vector GetCont
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::Namespace, NSD->isAnonymousNamespace()
-   ? ""
-   : NSD->getName().str());
+  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+NSD->isAnonymousNamespace() ? ""
+: 
NSD->getName().str());
+} else if (const auto *ED = dyn_cast(Context)) {
+  Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
+ED->getName().str());
 } else {
   const auto *RD = cast(Context);
-  Contexts.emplace_back(SymbolInfo::Record, RD->getName().str());
+  Contexts.emplace_back(SymbolInfo::ContextType::Record,
+RD->getName().str());
 }
   }
   return Contexts;
@@ -49,19 +60,24 @@ llvm::Optional CreateSymbolI
 const SourceManager &SM) {
   SymbolInfo::SymbolKind Type;
   if (llvm::isa(ND)) {
-Type = SymbolInfo::Variable;
+Type = SymbolInfo::SymbolKind::Variable;
   } else if (llvm::isa(ND)) {
-Type = SymbolInfo::Function;
+Type = SymbolInfo::SymbolKind::Function;
   } else if (llvm::isa(ND)) {
-Type = SymbolInfo::TypedefName;
+Type = SymbolInfo::SymbolKind::TypedefName;
+  } else if (llvm::isa(ND)) {
+Type = SymbolInfo::SymbolKind::EnumConstantDecl;
+  } else if (llvm::isa(ND)) {
+Type = SymbolInfo::SymbolKind::EnumDecl;
   } else {
-assert(llvm::isa(ND) && "Matched decl must be one of VarDecl, "
-"FunctionDecl, TypedefNameDecl and "
-"RecordDecl!");
+assert(llvm::isa(ND) &&
+   "Matched decl must be one of VarDecl, "
+   "FunctionDecl, TypedefNameDecl, EnumConstantDecl, "
+   "EnumDecl and RecordDecl!");
 // C-style record decl can have empty name, e.g "struct { ... } var;".
 if (ND->getName().empty())
   return llvm::None;
-Type = SymbolInfo::Class;
+Type = SymbolInfo::SymbolKind::Class;
   }
 
   SourceLocation Loc = SM.getExpansionLoc(ND->getLocation());
@@ -159,6 +175,23 @@ void FindAllSymbols::registerMatchers(Ma
   has

[clang-tools-extra] r269402 - clang-rename: check that the source location we find actually has the old name

2016-05-13 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Fri May 13 04:17:32 2016
New Revision: 269402

URL: http://llvm.org/viewvc/llvm-project?rev=269402&view=rev
Log:
clang-rename: check that the source location we find actually has the old name

This more general check could have prevented the specific problem
"getSourceOrder() == -1" guards.

Reviewers: cfe-commits, klimek

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

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.h

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=269402&r1=269401&r2=269402&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Fri May 13 04:17:32 
2016
@@ -49,7 +49,7 @@ public:
 std::vector NewCandidates;
 
 for (const auto &USR : USRs) {
-  NewCandidates = getLocationsOfUSR(USR, Context.getTranslationUnitDecl());
+  NewCandidates = getLocationsOfUSR(USR, PrevName, 
Context.getTranslationUnitDecl());
   RenamingCandidates.insert(RenamingCandidates.end(), 
NewCandidates.begin(),
 NewCandidates.end());
   NewCandidates.clear();

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=269402&r1=269401&r2=269402&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Fri May 13 04:17:32 
2016
@@ -20,6 +20,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Index/USRGeneration.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 
 using namespace llvm;
@@ -33,7 +34,7 @@ namespace {
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(const std::string USR) : USR(USR) {
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : 
USR(USR), PrevName(PrevName) {
   }
 
   // Declaration visitors:
@@ -58,6 +59,7 @@ public:
   }
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+const ASTContext &Context = ConstructorDecl->getASTContext();
 for (clang::CXXConstructorDecl::init_const_iterator it = 
ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
   const clang::CXXCtorInitializer* Initializer = *it;
   if (Initializer->getSourceOrder() == -1) {
@@ -68,7 +70,12 @@ public:
   if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
-  LocationsFound.push_back(Initializer->getSourceLocation());
+  SourceLocation Location = Initializer->getSourceLocation();
+  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Location), 
Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName == PrevName) {
+// The token of the source location we find actually has the old 
name.
+LocationsFound.push_back(Initializer->getSourceLocation());
+  }
 }
   }
 }
@@ -116,14 +123,17 @@ private:
   }
 
   // All the locations of the USR were found.
-  const std::string USR;
+  StringRef USR;
+  // Old name that is renamed.
+  StringRef PrevName;
   std::vector LocationsFound;
 };
 } // namespace
 
-std::vector getLocationsOfUSR(const std::string USR,
+std::vector getLocationsOfUSR(StringRef USR,
+  StringRef PrevName,
   Decl *Decl) {
-  USRLocFindingASTVisitor visitor(USR);
+  USRLocFindingASTVisitor visitor(USR, PrevName);
 
   visitor.TraverseDecl(Decl);
   return visitor.getLocationsFound();

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.h?rev=269402&r1=269401&r2=269402&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.h Fri May 13 04:17:32 2016
@@ -19,6 +19,8 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringRef.h"
+
 namespace clang {
 
 class Decl;
@@ -27,7 +29,8 @@ class SourceLocation;
 namespace rename {
 
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
-std::vector getLocationsOfUSR(const std::string usr,
+std::vec

Re: [PATCH] D20216: clang-rename: check that the source location we find actually has the old name

2016-05-13 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269402: clang-rename: check that the source location we find 
actually has the old name (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20216?vs=57140&id=57144#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20216

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.h

Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.h
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.h
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.h
@@ -19,15 +19,18 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringRef.h"
+
 namespace clang {
 
 class Decl;
 class SourceLocation;
 
 namespace rename {
 
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
-std::vector getLocationsOfUSR(const std::string usr,
+std::vector getLocationsOfUSR(llvm::StringRef usr,
+  llvm::StringRef PrevName,
   Decl *decl);
 }
 }
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
@@ -20,6 +20,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Index/USRGeneration.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 
 using namespace llvm;
@@ -33,7 +34,7 @@
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(const std::string USR) : USR(USR) {
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) {
   }
 
   // Declaration visitors:
@@ -58,6 +59,7 @@
   }
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+const ASTContext &Context = ConstructorDecl->getASTContext();
 for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
   const clang::CXXCtorInitializer* Initializer = *it;
   if (Initializer->getSourceOrder() == -1) {
@@ -68,7 +70,12 @@
   if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
-  LocationsFound.push_back(Initializer->getSourceLocation());
+  SourceLocation Location = Initializer->getSourceLocation();
+  StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts());
+  if (TokenName == PrevName) {
+// The token of the source location we find actually has the old name.
+LocationsFound.push_back(Initializer->getSourceLocation());
+  }
 }
   }
 }
@@ -116,14 +123,17 @@
   }
 
   // All the locations of the USR were found.
-  const std::string USR;
+  StringRef USR;
+  // Old name that is renamed.
+  StringRef PrevName;
   std::vector LocationsFound;
 };
 } // namespace
 
-std::vector getLocationsOfUSR(const std::string USR,
+std::vector getLocationsOfUSR(StringRef USR,
+  StringRef PrevName,
   Decl *Decl) {
-  USRLocFindingASTVisitor visitor(USR);
+  USRLocFindingASTVisitor visitor(USR, PrevName);
 
   visitor.TraverseDecl(Decl);
   return visitor.getLocationsFound();
Index: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
@@ -49,7 +49,7 @@
 std::vector NewCandidates;
 
 for (const auto &USR : USRs) {
-  NewCandidates = getLocationsOfUSR(USR, Context.getTranslationUnitDecl());
+  NewCandidates = getLocationsOfUSR(USR, PrevName, Context.getTranslationUnitDecl());
   RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(),
 NewCandidates.end());
   NewCandidates.clear();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r269403 - [include-fixer] Rename XrefsDB to SymbolIndex.

2016-05-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 13 04:27:54 2016
New Revision: 269403

URL: http://llvm.org/viewvc/llvm-project?rev=269403&view=rev
Log:
[include-fixer] Rename XrefsDB to SymbolIndex.

It's not really containing xrefs so the name didn't fit. No functional change.

Added:
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
clang-tools-extra/trunk/include-fixer/SymbolIndex.h
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/XrefsDB.h
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h
  - copied, changed from r269402, 
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
Removed:
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
clang-tools-extra/trunk/include-fixer/XrefsDB.h
clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
Modified:
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/docs/include-fixer.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/include-fixer.rst?rev=269403&r1=269402&r2=269403&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Fri May 13 04:27:54 2016
@@ -18,7 +18,7 @@ generated with existing tools.
 
 - Compilation database. Contains the compiler commands for any given file in a
   project and can be generated by CMake, see `How To Setup Tooling For LLVM`_.
-- Xrefs database. Contains all symbol information in a project to match a given
+- Symbol index. Contains all symbol information in a project to match a given
   identifier to a header file.
 
 Ideally both databases (``compile_commands.json`` and
@@ -30,7 +30,7 @@ so only implementation files can be hand
 
 .. _How To Setup Tooling For LLVM: 
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
-Creating an Xrefs Database From a Compilation Database
+Creating a Symbol Index From a Compilation Database
 --
 
 The include fixer contains :program:`find-all-symbols`, a tool to create a

Modified: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/CMakeLists.txt?rev=269403&r1=269402&r2=269403&view=diff
==
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Fri May 13 04:27:54 
2016
@@ -4,9 +4,9 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangIncludeFixer
   IncludeFixer.cpp
-  InMemoryXrefsDB.cpp
-  XrefsDBManager.cpp
-  YamlXrefsDB.cpp
+  InMemorySymbolIndex.cpp
+  SymbolIndexManager.cpp
+  YamlSymbolIndex.cpp
 
   LINK_LIBS
   clangAST

Copied: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp (from 
r269402, clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp?p2=clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp&p1=clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp&r1=269402&r2=269403&rev=269403&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp Fri May 13 
04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- InMemoryXrefsDB.cpp 
---===//
+//===-- 
InMemorySymbolIndex.cpp

Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-13 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 57145.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- Use reviewer's awesome templates for checkPair().
- Remove checkConstructorInitList().
- Moved InCtorInitializer context setting before checking tok::comma so that 
InCtorInitializer context can be set even we have syntax error ":," around ctor 
colon.


http://reviews.llvm.org/D19804

Files:
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -113,6 +113,133 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
+  std::string Code = "class A {\nA() : , {} };";
+  std::string Expected = "class A {\nA()  {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(19, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1) {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(23, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() :{} };";
+  Expected = "class A {\nA() {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(15, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, ListSimpleRedundantComma) {
+  std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }";
+  std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(40, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "int main() { f(1,,2,3,,4);}";
+  Expected = "int main() { f(1,2,3,4);}";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(22, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, CtorInitializationBracesInParens) {
+  std::string Code = "class A {\nA() : x({1}),, {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(24, 0));
+  Ranges.push_back(tooling::Range(26, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, RedundantCommaNotInAffectedRanges) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  std::string Expected =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  // Set the affected range to be "int x = 0", which does not intercept the
+  // constructor initialization list.
+  std::vector Ranges(1, tooling::Range(42, 9));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1), {} };";
+  // No range. Fixer should do nothing.
+  Ranges.clear();
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+// FIXME: delete comments too.
+TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
+  // Remove redundant commas around comment.
+  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
+  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(25, 0));
+  Ranges.push_back(tooling::Range(40, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), // comment\n{} };";
+  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Ranges = std::vector(1, tooling::Range(25, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
+  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Ranges = std::vector(1, tooling::Range(38, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
+  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Ranges = std::vector(1, tooling::Range(40, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : , // comment\n y(1),{} };";
+  Expected = "class A {\nA() :  // comment\n y(1){} };";
+  Ranges = std::vector(1, tooling::Range(17, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, CtorInitializerInNamespace) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace

Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-13 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1822
@@ +1821,3 @@
+cleanupRight(Line->First, Line->Last, tok::comma, tok::comma);
+checkConstructorInitList(*Line);
+  }

ioeric wrote:
> ioeric wrote:
> > djasper wrote:
> > > You could turn this into:
> > > 
> > > for (auto &Line : AnnotatedLines) {
> > >   if (Line->Affected) {
> > > cleanupRight(Line->First, tok::comma, tok::comma);
> > > cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
> > > cleanupLeft(Line->First, tok::comma, tok::l_brace);
> > > cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
> > >   }
> > > }
> > Wouldn't `cleanupLeft(Line->First, tok::comma, tok::l_brace);` also remove 
> > the comma from  `std::vector> = {{...}, {...}}`?
> I should've added this case into unit test, sorry...
> 
> But I think we can either handle constructor initializer's tok::l_brace 
> specially or annotate it? The later solution can enable us to do 
> `cleanupLeft(Line->First, tok::comma, TT_CtorInitializerLBrace);`.
Just found out constructor initializer's commas are already annotated. Then, 
this can be easily fixed with `cleanupLeft(Line->First, 
TT_CtorInitializerComma, tok::l_brace);`.


Comment at: lib/Format/Format.cpp:1914
@@ -1906,1 +1913,3 @@
 
+  FormatToken *getNextTokenNotDeletedUntilEnd(const FormatToken *Tok,
+  const FormatToken *End,

djasper wrote:
> And all of this into:
> 
>   // Checks pairs {start, start->next},..., {end->previous, end} and deletes 
> one
>   // of the token in the pair if the left token has \p LK token kind and the
>   // right token has \p RK token kind. If \p DeleteLeft is true, the left 
> token
>   // is deleted on match; otherwise, the right token is deleted.
>   template 
>   void cleanupPair(FormatToken *Start, LeftKind LK, RightKind RK,
>bool DeleteLeft) {
> auto NextNotDeleted = [this](const FormatToken &Tok) -> FormatToken * {
>   for (auto *Res = Tok.Next; Res; Res = Res->Next)
> if (!Res->is(tok::comment) &&
> DeletedTokens.find(Res) == DeletedTokens.end())
>   return Res;
>   return nullptr;
> };
> for (auto *Left = Start; Left;) {
>   auto *Right = NextNotDeleted(*Left);
>   if (!Right)
> break;
>   if (Left->is(LK) && Right->is(RK)) {
> deleteToken(DeleteLeft ? Left : Right);
> // If the right token is deleted, we should keep the left token
> // unchanged and pair it with the new right token.
> if (!DeleteLeft)
>   continue;
>   }
>   Left = Right;
> }
>   }
> 
>   template 
>   void cleanupLeft(FormatToken *Start, LeftKind LK, RightKind RK) {
> cleanupPair(Start, LK, RK, /*DeleteLeft=*/true);
>   }
> 
>   template 
>   void cleanupRight(FormatToken *Start, LeftKind LK, RightKind RK) {
> cleanupPair(Start, LK, RK, /*DeleteLeft=*/false);
>   }
> 
> 
Thanks for the awesome templates!


http://reviews.llvm.org/D19804



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


Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-13 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 57146.
ioeric added a comment.

- nit: add a missing space.


http://reviews.llvm.org/D19804

Files:
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -113,6 +113,133 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
+  std::string Code = "class A {\nA() : , {} };";
+  std::string Expected = "class A {\nA()  {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(19, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1) {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(23, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() :{} };";
+  Expected = "class A {\nA() {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(15, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, ListSimpleRedundantComma) {
+  std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }";
+  std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(40, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "int main() { f(1,,2,3,,4);}";
+  Expected = "int main() { f(1,2,3,4);}";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(22, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, CtorInitializationBracesInParens) {
+  std::string Code = "class A {\nA() : x({1}),, {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(24, 0));
+  Ranges.push_back(tooling::Range(26, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, RedundantCommaNotInAffectedRanges) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  std::string Expected =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  // Set the affected range to be "int x = 0", which does not intercept the
+  // constructor initialization list.
+  std::vector Ranges(1, tooling::Range(42, 9));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1), {} };";
+  // No range. Fixer should do nothing.
+  Ranges.clear();
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+// FIXME: delete comments too.
+TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
+  // Remove redundant commas around comment.
+  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
+  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(25, 0));
+  Ranges.push_back(tooling::Range(40, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), // comment\n{} };";
+  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Ranges = std::vector(1, tooling::Range(25, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
+  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Ranges = std::vector(1, tooling::Range(38, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
+  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Ranges = std::vector(1, tooling::Range(40, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and ignore comment.
+  Code = "class A {\nA() : , // comment\n y(1),{} };";
+  Expected = "class A {\nA() :  // comment\n y(1){} };";
+  Ranges = std::vector(1, tooling::Range(17, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, CtorInitializerInNamespace) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "class A { A() : x(0),, {} };\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace 

Re: r269398 - Add support for derived class special members hiding functions brought in from

2016-05-13 Thread Vassil Vassilev via cfe-commits

Hi Richard,
  I believe this broke our modules builds. Last successful one was with 
r269388 and the current with r269389 fails with:


/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 error: constructor cannot be redeclared
struct integral_constant
   ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 note: previous implicit declaration is here
struct integral_constant
   ^
/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TGenericClassInfo.cxx:18:10:
 fatal error: could not build module 'TCollectionProxyInfo.h'
#include "TCollectionProxyInfo.h"
 ^~~~
2 errors generated.

and

/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
error: multiple overloads of 'nothrow_t' instantiate to the same signature 
'void ()'
  struct nothrow_t { };
 ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:253:8: note: in 
instantiation of function template specialization '__gnu_cxx::new_allocator 
>::construct, const std::pair &>' requested here
{ __a.construct(__p, std::forward<_Args>(__args)...); }
  ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:399:4: note: in instantiation 
of function template specialization 'std::allocator_traits > 
>::_S_construct, const std::pair &>' requested here
{ _S_construct(__a, __p, std::forward<_Args>(__args)...); }
  ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/stl_vector.h:917:21: note: in instantiation 
of function template specialization 'std::allocator_traits > 
>::construct, const std::pair &>' requested here
_Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
   ^
/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TSchemaRule.cxx:873:21:
 note: in instantiation of member function 'std::vector, 
std::allocator > >::push_back' requested here
  fVersionVect->push_back( verpair );
^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
note: previous implicit declaration is here
  struct nothrow_t { };

Shall I start reducing the issues one by one or we can revert this 
patch? Vassil On 13/05/16 08:47, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri May 13 01:47:56 2016
New Revision: 269398

URL: http://llvm.org/viewvc/llvm-project?rev=269398&view=rev
Log:
Add support for derived class special members hiding functions brought in from
a base class via a using-declaration. If a class has a using-declaration
declaring either a constructor or an assignment operator, eagerly declare its
special members in case they need to displace a shadow declaration from a
using-declaration.

Modified:
 cfe/trunk/include/clang/AST/DeclCXX.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
 cfe/trunk/test/SemaCUDA/implicit-member-target.cu
 cfe/trunk/test/SemaCXX/constructor-recovery.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=269398&r1=269397&r2=269398&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 13 01:47:56 2016
@@ -382,6 +382,14 @@ class CXXRecordDecl : public RecordDecl
  /// provided default ctor also doesn't have an in-class initializer.
  unsigned HasUninitializedFields : 1;
  
+/// \brief True if there are any member using-declarations that inherit

+/// constructors from a base class.
+unsigned HasInheritedConstructor : 1;
+
+/// \brief True if there are any member using-declarations named
+/// 'operator='.
+unsigned HasInheritedAssignment : 1;
+
  /// \brief These flags are \c true if a defaulted corresponding special
  /// member can't be fully analyzed without performing overload resolution.
  /// @{
@@ -1308,6 +1316,18 @@ public:
  return data().HasNonLiteralTypeFieldsOrBases;
}
  
+  /// \brief Determine whether this class has a using-declaration that names

+  /// a base class constructor.
+  bool hasInheritedConstructor() const {
+return data().HasInheritedConstructor;
+  }
+
+  /// \brief Determine whether this class has a using-declaration that names
+  /// a base class assignment operator.
+  bool h

Re: [PATCH] D20232: [include-fixer] Simplify unittest code.

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

What's a flexable (in the description)? Code LG.


Repository:
  rL LLVM

http://reviews.llvm.org/D20232



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


Re: [PATCH] D20232: [include-fixer] Simplify unittest code.

2016-05-13 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D20232#429348, @bkramer wrote:

> What's a flexable (in the description)? Code LG.


I updated the description now.


Repository:
  rL LLVM

http://reviews.llvm.org/D20232



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


Re: [PATCH] D20205: [include-fixer] Use scope contexts information to improve query.

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

Tests look much better now, thanks!


http://reviews.llvm.org/D20205



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


Re: [PATCH] D20232: [include-fixer] Simplify unittest code.

2016-05-13 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

So s/flexable/flexible/ and commit :)


Repository:
  rL LLVM

http://reviews.llvm.org/D20232



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


r269411 - [mips] Consult triple's vendor field before using musl's interpreter.

2016-05-13 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Fri May 13 07:13:13 2016
New Revision: 269411

URL: http://llvm.org/viewvc/llvm-project?rev=269411&view=rev
Log:
[mips] Consult triple's vendor field before using musl's interpreter.

This should affect only the mips-mti-linux toolchain.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=269411&r1=269410&r2=269411&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri May 13 07:13:13 2016
@@ -8991,7 +8991,9 @@ static std::string getLinuxDynamicLinker
 bool IsNaN2008 = mips::isNaN2008(Args, ToolChain.getTriple());
 if (mips::isUCLibc(Args))
   LibName = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
-else if (!ToolChain.getTriple().hasEnvironment()) {
+else if (!ToolChain.getTriple().hasEnvironment() &&
+ ToolChain.getTriple().getVendor() ==
+ llvm::Triple::VendorType::MipsTechnologies) {
   bool LE = (ToolChain.getTriple().getArch() == llvm::Triple::mipsel) ||
 (ToolChain.getTriple().getArch() == llvm::Triple::mips64el);
   LibName = LE ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";


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


r269412 - Simplify getLinuxDynamicLinker() by using a common variable for the triple. NFC.

2016-05-13 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Fri May 13 07:34:14 2016
New Revision: 269412

URL: http://llvm.org/viewvc/llvm-project?rev=269412&view=rev
Log:
Simplify getLinuxDynamicLinker() by using a common variable for the triple. NFC.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=269412&r1=269411&r2=269412&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri May 13 07:34:14 2016
@@ -8957,9 +8957,10 @@ static void AddLibgcc(const llvm::Triple
 static std::string getLinuxDynamicLinker(const ArgList &Args,
  const toolchains::Linux &ToolChain) {
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
+  const llvm::Triple &Triple = ToolChain.getTriple();
 
-  if (ToolChain.getTriple().isAndroid()) {
-if (ToolChain.getTriple().isArch64Bit())
+  if (Triple.isAndroid()) {
+if (Triple.isArch64Bit())
   return "/system/bin/linker64";
 else
   return "/system/bin/linker";
@@ -8971,31 +8972,29 @@ static std::string getLinuxDynamicLinker
   else if (Arch == llvm::Triple::aarch64_be)
 return "/lib/ld-linux-aarch64_be.so.1";
   else if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {
-if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF ||
+if (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
 arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard)
   return "/lib/ld-linux-armhf.so.3";
 else
   return "/lib/ld-linux.so.3";
   } else if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) {
 // TODO: check which dynamic linker name.
-if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF ||
+if (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
 arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard)
   return "/lib/ld-linux-armhf.so.3";
 else
   return "/lib/ld-linux.so.3";
   } else if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel ||
  Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el) {
-std::string LibDir =
-"/lib" + mips::getMipsABILibSuffix(Args, ToolChain.getTriple());
+std::string LibDir = "/lib" + mips::getMipsABILibSuffix(Args, Triple);
 StringRef LibName;
-bool IsNaN2008 = mips::isNaN2008(Args, ToolChain.getTriple());
+bool IsNaN2008 = mips::isNaN2008(Args, Triple);
 if (mips::isUCLibc(Args))
   LibName = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
-else if (!ToolChain.getTriple().hasEnvironment() &&
- ToolChain.getTriple().getVendor() ==
- llvm::Triple::VendorType::MipsTechnologies) {
-  bool LE = (ToolChain.getTriple().getArch() == llvm::Triple::mipsel) ||
-(ToolChain.getTriple().getArch() == llvm::Triple::mips64el);
+else if (!Triple.hasEnvironment() &&
+ Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies) 
{
+  bool LE = (Triple.getArch() == llvm::Triple::mipsel) ||
+(Triple.getArch() == llvm::Triple::mips64el);
   LibName = LE ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";
 } else
   LibName = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
@@ -9016,7 +9015,7 @@ static std::string getLinuxDynamicLinker
   else if (Arch == llvm::Triple::sparcv9)
 return "/lib64/ld-linux.so.2";
   else if (Arch == llvm::Triple::x86_64 &&
-   ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUX32)
+   Triple.getEnvironment() == llvm::Triple::GNUX32)
 return "/libx32/ld-linux-x32.so.2";
   else
 return "/lib64/ld-linux-x86-64.so.2";


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


Re: r269309 - [ubsan] Add -fsanitize-undefined-strip-path-components=N

2016-05-13 Thread Filipe Cabecinhas via cfe-commits

> On 13 May 2016, at 07:03, Sean Silva  wrote:
> 
> 
> 
> On Thu, May 12, 2016 at 9:51 AM, Filipe Cabecinhas via cfe-commits 
>  wrote:
> Author: filcab
> Date: Thu May 12 11:51:36 2016
> New Revision: 269309
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269309&view=rev
> Log:
> [ubsan] Add -fsanitize-undefined-strip-path-components=N
> 
> Summary:
> This option allows the user to control how much of the file name is
> emitted by UBSan. Tuning this option allows one to save space in the
> resulting binary, which is helpful for restricted execution
> environments.
> 
> With a positive N, UBSan skips the first N path components.
> With a negative N, UBSan only keeps the last N path components.
> 
> Reviewers: rsmith
> 
> Subscribers: cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D19666
> 
> Added:
> cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
> cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> 
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=269309&r1=269308&r2=269309&view=diff
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu May 12 11:51:36 2016
> @@ -228,6 +228,26 @@ UndefinedBehaviorSanitizer is available
>  3.3. The test suite is integrated into the CMake build and can be run with
>  ``check-ubsan`` command.
> 
> +Additional Configuration
> +
> +
> +UndefinedBehaviorSanitizer adds static check data for each check unless it is
> +in trap mode. This check data includes the full file name. The option
> +``-fsanitize-undefined-strip-path-components=N`` can be used to trim this
> +information. If ``N`` is positive, file information emitted by
> +UndefinedBehaviorSanitizer will drop the first ``N`` components from the file
> +path. If ``N`` is negative, the last ``N`` components will be kept.
> +
> +Example
> +---
> +
> +For a file called ``/code/library/file.cpp``, here is what would be emitted:
> +* Default (No flag, or ``-fsanitize-undefined-strip-path-components=0``): 
> ``/code/library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=1``: ``code/library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=2``: ``library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=-1``: ``file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=-2``: ``library/file.cpp``
> 
> How are drive letters handled?
> 
> -- Sean Silva

Same way as Path iterator:
///   /  => /
///   /foo   => /,foo
///   foo/   => foo,.
///   /foo/bar   => /,foo,bar
///   ../=> ..,.
///   C:\foo\bar => C:,/,foo,bar

  Filipe

>  
> +
>  More Information
>  
> 
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269309&r1=269308&r2=269309&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu May 12 11:51:36 2016
> @@ -677,6 +677,10 @@ def fsanitize_stats : Flag<["-"], "fsani
>  def fno_sanitize_stats : Flag<["-"], "fno-sanitize-stats">,
>   Group, Flags<[CC1Option]>,
>   HelpText<"Disable sanitizer statistics 
> gathering.">;
> +def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], 
> "fsanitize-undefined-strip-path-components=">,
> +  Group, Flags<[CC1Option]>, MetaVarName<"">,
> +  HelpText<"Strip (or keep only, if negative) a given number of path 
> components "
> +   "when emitting check metadata.">;
>  def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,
>Group;
>  def fno_unsafe_math_optimizations : Flag<["-"], 
> "fno-unsafe-math-optimizations">,
> 
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=269309&r1=269308&r2=269309&view=diff
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu May 12 11:51:36 
> 2016
> @@ -225,6 +225,10 @@ ENUM_CODEGENOPT(VecLib, VectorLibrary, 1
>  /// The default TLS model to use.
>  ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
> 
> +/// Number of path components to strip wh

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

2016-05-13 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 57172.

http://reviews.llvm.org/D20196

Files:
  clang-tidy/performance/InefficientStringAdditionCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/performance-inefficient-string-addition.rst
  test/clang-tidy/performance-inefficient-string-addition.cpp

Index: test/clang-tidy/performance-inefficient-string-addition.cpp
===
--- test/clang-tidy/performance-inefficient-string-addition.cpp
+++ test/clang-tidy/performance-inefficient-string-addition.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-inefficient-string-addition %t -- -- -std=c++11
+// RUN: %check_clang_tidy %s performance-inefficient-string-addition %t
 
 namespace std {
 template 
@@ -24,11 +24,11 @@
 f(mystr1 + mystr2 + mystr1);
 // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: Inefficient string concatenation
 mystr1 = mystr1 + mystr2;
-// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: Ineff
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Ineff
 mystr1 = mystr2 + mystr2 + mystr2;
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: Ineff
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: Ineff
 mystr1 = mystr2 + mystr1;
-// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: Ineff
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Ineff
 mywstr1 = mywstr2 + mywstr1;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Ineff
 mywstr1 = mywstr2 + mywstr2 + mywstr2;
@@ -41,4 +41,4 @@
 mystr1 = g(mystr1);
   }
   return 0;
-}
\ No newline at end of file
+}
Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- docs/clang-tidy/checks/performance-inefficient-string-addition.rst
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -1,24 +1,22 @@
 .. title:: clang-tidy - performance-inefficient-string-addition
 
 performance-inefficient-string-addition
-=
+===
 
 The problem
---
+---
 This check is to warn about the performance overhead arising from concatenating strings, using the operator+, for instance:
 
 .. code:: c++
 
-
-std::string a = "Foo", b = "Bar";
+std::string a("Foo"), b("Bar");
 a = a + b;
 
-Instead of this structure you should use **operator+=** or std::string's (std::basic_string) class member function **append**. For instance:
+Instead of this structure you should use `operator+=` or std::string's (std::basic_string) class member function `append`. For instance:

 .. code:: c++
 
-   
-   std::string a = "Foo", b = "Baz";
+   std::string a("Foo"), b("Baz");
for(int i = 0; i < 2; ++i)
{
a = a + "Bar" + b;
@@ -28,7 +26,7 @@
 
 .. code:: c++
 
-   std::string a = "Foo", b = "Baz";
+   std::string a("Foo"), b("Baz");
for(int i = 0; i < 2; ++i)
{
a.append("Bar").append(b);
@@ -39,19 +37,19 @@
  .. code:: c++
   
void f(const std::string&){}
-   std::string a = "Foo", b = "Baz";
+   std::string a("Foo"), b("Baz");
void g()
{
-   f(a+"Bar"+b);
+   f(a + "Bar" + b);
}
 
 In a slightly more efficient way like:
 
 .. code:: c++
 
void f(const std::string&){}
-   std::string a = "Foo", b = "Baz";
+   std::string a("Foo"), b("Baz");
void g()
{
f(std::string(a).append("Bar").append(b));
-   }
\ No newline at end of file
+   }
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -184,6 +184,12 @@
   Warns about range-based loop with a loop variable of const ref type where the
   type of the variable does not match the one returned by the iterator.
 
+- New `performance-inefficient-string-addition
+  `_ check
+
+  This check is to warn about the performance overhead arising from concatenating 
+  strings, using the operator+, instead of operator+=.
+  
 - New `performance-unnecessary-value-param
   `_ check
 
Index: clang-tidy/performance/InefficientStringAdditionCheck.cpp
===
--- clang-tidy/performance/InefficientStringAdditionCheck.cpp
+++ clang-tidy/performance/InefficientStringAdditionCheck.cpp
@@ -28,22 +28,22 @@
   IsStrictMode(Options.get("isStrictMode", 0)) {}
 
 void InefficientStringAdditionCheck::registerMatchers(MatchFinder *Finder) {
-  auto BasicStringType = hasType(cxxRecordDecl(hasName("::std::basic_string")));
+  const auto BasicStringType = hasType(cxxRecordDecl(hasName("::std::basic_string")));
 
-  auto BasicStringPlusOperator =
+  const auto BasicStringPlusOperator =
   cxxOperatorCallExpr(hasAnyArgument(ignoringImpCasts(declRefExpr(Bas

Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-13 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for this!


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-13 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek added a comment.

+1 I will probably also use this.

Does hasCastKind works for implicitCastExpr?


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-13 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D19871#429153, @etienneb wrote:

> In http://reviews.llvm.org/D19871#428997, @jroelofs wrote:
>
> > Drive-by thought: I think it would be useful to be able to match implicit 
> > casts separately from explicit casts when using this new matcher.
>
>
> Jonathan, I think what you are asking for is already supported.
>  I added an unittest to confirm it.
>
>   EXPECT_TRUE(matches("char *p = 0;",
>   implicitCastExpr(hasCastKind(CK_NullToPointer;
>   
>
> If I misunderstood your comment, could you provide an example.


Oh, right. That /is/ exactly what I meant. Excellent.


http://reviews.llvm.org/D19871



___
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-13 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: docs/ReleaseNotes.rst:191
@@ +190,3 @@
+  This check is to warn about the performance overhead arising from 
concatenating 
+  strings, using the operator+, instead of operator+=.
+  

Please highlight operator+ and operator+= with ``.


http://reviews.llvm.org/D20196



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


Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 57177.
yaxunl added a comment.

Fixed available OpenCL version for some extensions.


http://reviews.llvm.org/D19484

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/LangOptions.h
  include/clang/Basic/OpenCLExtensions.def
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/Sema.cpp
  test/CodeGenOpenCL/builtins-r600.cl
  test/CodeGenOpenCL/fpmath.cl
  test/CodeGenOpenCL/half.cl
  test/Lexer/opencl-half-literal.cl
  test/Misc/languageOptsOpenCL.cl
  test/PCH/opencl-extensions.cl
  test/Parser/opencl-astype.cl
  test/Parser/opencl-atomics-cl20.cl
  test/Parser/opencl-pragma.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/extension-fp64-cl1.1.cl
  test/SemaOpenCL/extension-fp64.cl
  test/SemaOpenCL/extensions.cl
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  test/SemaOpenCL/invalid-logical-ops-1.2.cl
  test/SemaOpenCL/optional-core-fp64-cl1.2.cl
  test/SemaOpenCL/optional-core-fp64-cl2.0.cl

Index: test/SemaOpenCL/optional-core-fp64-cl2.0.cl
===
--- test/SemaOpenCL/optional-core-fp64-cl2.0.cl
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
-// expected-no-diagnostics
-
-void f1(double da) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d;
-}
Index: test/SemaOpenCL/optional-core-fp64-cl1.2.cl
===
--- test/SemaOpenCL/optional-core-fp64-cl1.2.cl
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// expected-no-diagnostics
-
-void f1(double da) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d;
-}
Index: test/SemaOpenCL/invalid-logical-ops-1.2.cl
===
--- test/SemaOpenCL/invalid-logical-ops-1.2.cl
+++ test/SemaOpenCL/invalid-logical-ops-1.2.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu
 
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable // expected-warning{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}}
+
 typedef __attribute__((ext_vector_type(4))) float float4;
 typedef __attribute__((ext_vector_type(4))) double double4;
 typedef __attribute__((ext_vector_type(4))) int int4;
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
Index: test/SemaOpenCL/extensions.cl
===
--- /dev/null
+++ test/SemaOpenCL/extensions.cl
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+
+// Test with a target not supporting fp64.
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
+
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#ifdef NOFP64
+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
+#endif
+
+void f2(void) {
+  double d;
+#ifdef NOFP64
+// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
+#endif
+
+  (void) 1.0;
+#ifdef NOFP64
+// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting 

Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: lib/Driver/MSVCToolChain.cpp:42
@@ -40,1 +41,3 @@
+
+  #pragma comment(lib, "version.lib")
 #endif

Eh, I am lightening up on this sort of thing, so this is fine by me.


Comment at: lib/Driver/MSVCToolChain.cpp:467
@@ +466,3 @@
+  std::string BinPath;
+  if (!getVisualStudioBinariesFolder("", BinPath)) {
+return Version;

Elide braces (here and elsewhere) per usual project coding conventions.


Comment at: lib/Driver/MSVCToolChain.cpp:483
@@ +482,3 @@
+  }
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

Pure pedantry: `uint8_t` instead of `char`, or is this data really a textual 
string in practice?


http://reviews.llvm.org/D20136



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


r269418 - [AST] Add missing const qualifiers to AstContext in Type.cpp

2016-05-13 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Fri May 13 09:31:44 2016
New Revision: 269418

URL: http://llvm.org/viewvc/llvm-project?rev=269418&view=rev
Log:
[AST] Add missing const qualifiers to AstContext in Type.cpp

Summary:
Add some missing const qualifiers to AstContext.
The ASTContext can't be modified with accessors.

There is no behavior change. This patch is cleanup only.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269418&r1=269417&r2=269418&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri May 13 09:31:44 2016
@@ -722,27 +722,27 @@ public:
   /// applied to this type.
   unsigned getCVRQualifiers() const;
 
-  bool isConstant(ASTContext& Ctx) const {
+  bool isConstant(const ASTContext& Ctx) const {
 return QualType::isConstant(*this, Ctx);
   }
 
   /// \brief Determine whether this is a Plain Old Data (POD) type (C++ 
3.9p10).
-  bool isPODType(ASTContext &Context) const;
+  bool isPODType(const ASTContext &Context) const;
 
   /// Return true if this is a POD type according to the rules of the C++98
   /// standard, regardless of the current compilation's language.
-  bool isCXX98PODType(ASTContext &Context) const;
+  bool isCXX98PODType(const ASTContext &Context) const;
 
   /// Return true if this is a POD type according to the more relaxed rules
   /// of the C++11 standard, regardless of the current compilation's language.
   /// (C++0x [basic.types]p9)
-  bool isCXX11PODType(ASTContext &Context) const;
+  bool isCXX11PODType(const ASTContext &Context) const;
 
   /// Return true if this is a trivial type per (C++0x [basic.types]p9)
-  bool isTrivialType(ASTContext &Context) const;
+  bool isTrivialType(const ASTContext &Context) const;
 
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
-  bool isTriviallyCopyableType(ASTContext &Context) const;
+  bool isTriviallyCopyableType(const ASTContext &Context) const;
 
   // Don't promise in the API that anything besides 'const' can be
   // easily added.
@@ -1084,7 +1084,7 @@ private:
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
   // caller.
-  static bool isConstant(QualType T, ASTContext& Ctx);
+  static bool isConstant(QualType T, const ASTContext& Ctx);
   static QualType getDesugaredType(QualType T, const ASTContext &Context);
   static SplitQualType getSplitDesugaredType(QualType T);
   static SplitQualType getSplitUnqualifiedTypeImpl(QualType type);
@@ -1619,7 +1619,7 @@ public:
   bool isChar16Type() const;
   bool isChar32Type() const;
   bool isAnyCharacterType() const;
-  bool isIntegralType(ASTContext &Ctx) const;
+  bool isIntegralType(const ASTContext &Ctx) const;
 
   /// Determine whether this type is an integral or enumeration type.
   bool isIntegralOrEnumerationType() const;
@@ -2513,13 +2513,13 @@ public:
 
   /// \brief Determine the number of bits required to address a member of
   // an array with the given element type and number of elements.
-  static unsigned getNumAddressingBits(ASTContext &Context,
+  static unsigned getNumAddressingBits(const ASTContext &Context,
QualType ElementType,
const llvm::APInt &NumElements);
 
   /// \brief Determine the maximum number of active bits that an array's size
   /// can require, which limits the maximum size of the array.
-  static unsigned getMaxSizeBits(ASTContext &Context);
+  static unsigned getMaxSizeBits(const ASTContext &Context);
 
   void Profile(llvm::FoldingSetNodeID &ID) {
 Profile(ID, getElementType(), getSize(),
@@ -3004,7 +3004,7 @@ public:
 
   /// \brief Determine the type of an expression that calls a function of
   /// this type.
-  QualType getCallResultType(ASTContext &Context) const {
+  QualType getCallResultType(const ASTContext &Context) const {
 return getReturnType().getNonLValueExprType(Context);
   }
 

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=269418&r1=269417&r2=269418&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri May 13 09:31:44 2016
@@ -64,7 +64,7 @@ const IdentifierInfo* QualType::getBaseT
   return nullptr;
 }
 
-bool QualType::isConstant(QualType T, ASTContext &Ctx) {
+bool QualType::isConstant(QualType T, const ASTContext &Ctx) {
   if (T.isConstQualified())
 return true;
 
@@ -74,7 +74,7 @@ bool QualType::isConstant(QualType T, AS
   return T.getAddressSpace() == LangAS::ope

Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Alexey Bader via cfe-commits
bader accepted this revision.
bader added a comment.

LGTM. Thanks!


http://reviews.llvm.org/D19484



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-13 Thread Yaxun Liu via cfe-commits
yaxunl marked 3 inline comments as done.


Comment at: lib/Headers/opencl-c.h:14057
@@ +14056,3 @@
+event_t __attribute__((overloadable)) async_work_group_copy(__local float2 
*dst, const __global float2 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local char3 
*dst, const __global char3 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local uchar3 
*dst, const __global uchar3 *src, size_t num_elements, event_t event);

Anastasia wrote:
> yaxunl wrote:
> > If this representation is not generic enough. Any suggestion for an 
> > alternative? Thanks.
> I don't think Spec imposes any specific implementation of this macro.
> 
> I am thinking we might better leave it out to allow adding in a way suitable 
> for other implementations.
How about this?

  #ifndef ATOMIC_VAR_INIT
  #define ATOMIC_VAR_INIT(x) (x)
  #endif

This way we have a default declaration and also allows user to override it.

Another way is to remove it from header and define it in Clang on target by 
target basis.



http://reviews.llvm.org/D18369



___
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-13 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/modernize/UseNoexceptCheck.h:44-45
@@ +43,4 @@
+   unsigned &Len);
+  const std::string ReplacementStr;
+  StringRef Replacement;
+};

What is the difference between these two fields? The names are kind of 
confusing to me given their similarity, so perhaps renaming one to be more 
descriptive would be useful.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-13 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D19871#429466, @Prazek wrote:

> +1 I will probably also use this.
>
> Does hasCastKind works for implicitCastExpr?


Yes, there is a unittest with the code.


http://reviews.llvm.org/D19871



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


Re: [PATCH] D20219: [CodeGen] Clang does not choose aapcs-vfp calling convention for ARM bare metal target with hard float (EABIHF)

2016-05-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269419: [CodeGen] Clang does not choose aapcs-vfp calling 
convention for ARM bare… (authored by oleg).

Changed prior to commit:
  http://reviews.llvm.org/D20219?vs=57082&id=57187#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20219

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/arm-cc.c

Index: cfe/trunk/test/CodeGen/arm-cc.c
===
--- cfe/trunk/test/CodeGen/arm-cc.c
+++ cfe/trunk/test/CodeGen/arm-cc.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs  -emit-llvm 
-w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu 
-emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi aapcs  
-emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-AAPCS %s
+// RUN: %clang_cc1 -triple armv7-none-eabihf -target-abi aapcs-vfp -emit-llvm 
-w -o - %s | FileCheck -check-prefix=BAREMETAL-AAPCS_VFP %s
 
 
 // DARWIN-APCS-LABEL: define void @f()
@@ -13,6 +14,9 @@
 // LINUX-APCS: call arm_apcscc void @g
 // LINUX-AAPCS-LABEL: define void @f()
 // LINUX-AAPCS: call void @g
+// BAREMETAL-AAPCS_VFP-LABEL: define void @f()
+// BAREMETAL-AAPCS_VFP: call void @g
+// BAREMETAL-AAPCS_VFP: declare void @g()
 void g(void);
 void f(void) {
   g();
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7878,7 +7878,8 @@
   Kind = ARMABIInfo::AAPCS16_VFP;
 else if (CodeGenOpts.FloatABI == "hard" ||
  (CodeGenOpts.FloatABI != "soft" &&
-  Triple.getEnvironment() == llvm::Triple::GNUEABIHF))
+  (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
+   Triple.getEnvironment() == llvm::Triple::EABIHF)))
   Kind = ARMABIInfo::AAPCS_VFP;
 
 return SetCGInfo(new ARMTargetCodeGenInfo(Types, Kind));


Index: cfe/trunk/test/CodeGen/arm-cc.c
===
--- cfe/trunk/test/CodeGen/arm-cc.c
+++ cfe/trunk/test/CodeGen/arm-cc.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs  -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi aapcs  -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-AAPCS %s
+// RUN: %clang_cc1 -triple armv7-none-eabihf -target-abi aapcs-vfp -emit-llvm -w -o - %s | FileCheck -check-prefix=BAREMETAL-AAPCS_VFP %s
 
 
 // DARWIN-APCS-LABEL: define void @f()
@@ -13,6 +14,9 @@
 // LINUX-APCS: call arm_apcscc void @g
 // LINUX-AAPCS-LABEL: define void @f()
 // LINUX-AAPCS: call void @g
+// BAREMETAL-AAPCS_VFP-LABEL: define void @f()
+// BAREMETAL-AAPCS_VFP: call void @g
+// BAREMETAL-AAPCS_VFP: declare void @g()
 void g(void);
 void f(void) {
   g();
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7878,7 +7878,8 @@
   Kind = ARMABIInfo::AAPCS16_VFP;
 else if (CodeGenOpts.FloatABI == "hard" ||
  (CodeGenOpts.FloatABI != "soft" &&
-  Triple.getEnvironment() == llvm::Triple::GNUEABIHF))
+  (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
+   Triple.getEnvironment() == llvm::Triple::EABIHF)))
   Kind = ARMABIInfo::AAPCS_VFP;
 
 return SetCGInfo(new ARMTargetCodeGenInfo(Types, Kind));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r269422 - [find-all-symbols] Add EnumDecl type in YAML traits.

2016-05-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 13 09:53:10 2016
New Revision: 269422

URL: http://llvm.org/viewvc/llvm-project?rev=269422&view=rev
Log:
[find-all-symbols] Add EnumDecl type in YAML traits.

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

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=269422&r1=269421&r2=269422&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Fri 
May 13 09:53:10 2016
@@ -40,6 +40,7 @@ template <> struct ScalarEnumerationTrai
   static void enumeration(IO &io, ContextType &value) {
 io.enumCase(value, "Record", ContextType::Record);
 io.enumCase(value, "Namespace", ContextType::Namespace);
+io.enumCase(value, "EnumDecl", ContextType::EnumDecl);
   }
 };
 


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


r269423 - Prune four superfluous ExternalSemaSource.h includes and one forward declaration in Sema.h

2016-05-13 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri May 13 09:53:19 2016
New Revision: 269423

URL: http://llvm.org/viewvc/llvm-project?rev=269423&view=rev
Log:
Prune four superfluous ExternalSemaSource.h includes and one forward 
declaration in Sema.h
where ExternalSemaSource.h was already included due to ExternalSemaSource:: 
member uses.


Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseAST.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=269423&r1=269422&r2=269423&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 13 09:53:19 2016
@@ -109,7 +109,6 @@ namespace clang {
   class EnumConstantDecl;
   class Expr;
   class ExtVectorType;
-  class ExternalSemaSource;
   class FormatAttr;
   class FriendDecl;
   class FunctionDecl;

Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=269423&r1=269422&r2=269423&view=diff
==
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Fri May 13 09:53:19 2016
@@ -19,7 +19,6 @@
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
-#include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "llvm/Support/CrashRecoveryContext.h"

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=269423&r1=269422&r2=269423&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri May 13 09:53:19 2016
@@ -19,7 +19,6 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
-#include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Scope.h"

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=269423&r1=269422&r2=269423&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri May 13 09:53:19 2016
@@ -21,7 +21,6 @@
 #include "clang/AST/ExprObjC.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Sema/DeclSpec.h"
-#include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=269423&r1=269422&r2=269423&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri May 13 09:53:19 2016
@@ -29,7 +29,6 @@
 #include "clang/Lex/ModuleLoader.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
-#include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"


___
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-13 Thread don hinton via cfe-commits
hintonda added inline comments.


Comment at: clang-tidy/modernize/UseNoexceptCheck.h:44-45
@@ +43,4 @@
+   unsigned &Len);
+  const std::string ReplacementStr;
+  StringRef Replacement;
+};

aaron.ballman wrote:
> What is the difference between these two fields? The names are kind of 
> confusing to me given their similarity, so perhaps renaming one to be more 
> descriptive would be useful.
The first is the option passed in, i.e., the replacement string we will use 
(either noexcept or a user macro like libcxx's _NOEXCEPT) for throw() and the 
second one is the string we'll actually use for a particular replacement, which 
can be what the user supplied, or noexcept(false) when the function can throw.

This was originally done with an auto in check(), but Alex wanted me to add a 
helper function to make check() easier to understand.  So, I had to put it 
somewhere.  I actually prefer the simpler original version.

I'll see if I can come up with better names, but suggestions are always welcome.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D20232: [include-fixer] Simplify unittest code.

2016-05-13 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57193.
hokein updated the summary for this revision.
hokein added a comment.

Fix clang-include-fixer build.


http://reviews.llvm.org/D20232

Files:
  include-fixer/InMemorySymbolIndex.cpp
  include-fixer/InMemorySymbolIndex.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/tool/ClangIncludeFixer.cpp
  unittests/include-fixer/IncludeFixerTest.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -89,12 +89,6 @@
   MockReporter Reporter;
 };
 
-SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
-StringRef FilePath, int LineNumber,
-const std::vector &Contexts) {
-  return SymbolInfo(Name, Type, FilePath, Contexts, LineNumber);
-}
-
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
   static const char Code[] = R"(
   extern int xargc;
@@ -104,19 +98,17 @@
   })";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol = CreateSymbolInfo(
-  "xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
+  SymbolInfo Symbol =
+  SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol =
-  CreateSymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
-   {{SymbolInfo::ContextType::Namespace, "na"}});
+  Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol =
-  CreateSymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5,
-   {{SymbolInfo::ContextType::Namespace, "nb"},
-{SymbolInfo::ContextType::Namespace, "na"}});
+  Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5,
+  {{SymbolInfo::ContextType::Namespace, "nb"},
+   {SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -130,12 +122,12 @@
   })";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol = CreateSymbolInfo(
-  "C_Func", SymbolInfo::SymbolKind::Function, HeaderName, 3, {});
+  SymbolInfo Symbol =
+  SymbolInfo("C_Func", SymbolInfo::SymbolKind::Function, HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("C_struct", SymbolInfo::SymbolKind::Class,
-HeaderName, 4, {});
+  Symbol =
+  SymbolInfo("C_struct", SymbolInfo::SymbolKind::Class, HeaderName, 4, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -155,17 +147,17 @@
   )";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol = CreateSymbolInfo("Glob", SymbolInfo::SymbolKind::Class,
-   HeaderName, 2, {});
+  SymbolInfo Symbol =
+  SymbolInfo("Glob", SymbolInfo::SymbolKind::Class, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("A", SymbolInfo::SymbolKind::Class, HeaderName, 6,
-{{SymbolInfo::ContextType::Namespace, "na"}});
+  Symbol = SymbolInfo("A", SymbolInfo::SymbolKind::Class, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("AAA", SymbolInfo::SymbolKind::Class, HeaderName, 7,
-{{SymbolInfo::ContextType::Record, "A"},
- {SymbolInfo::ContextType::Namespace, "na"}});
+  Symbol = SymbolInfo("AAA", SymbolInfo::SymbolKind::Class, HeaderName, 7,
+  {{SymbolInfo::ContextType::Record, "A"},
+   {SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_FALSE(hasSymbol(Symbol));
 }
 
@@ -187,8 +179,8 @@
   )";
   runFindAllSymbols(Code);
 
-  SymbolInfo Symbol = CreateSymbolInfo("T_TEMP", SymbolInfo::SymbolKind::Class,
-   HeaderName, 3, {});
+  SymbolInfo Symbol =
+  SymbolInfo("T_TEMP", SymbolInfo::SymbolKind::Class, HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
@@ -209,22 +201,21 @@
   runFindAllSymbols(Code);
 
   SymbolInfo Symbol =
-  CreateSymbolInfo("gg", SymbolInfo::SymbolKind::Function, HeaderName, 3,
-   {{SymbolInfo::ContextType::Namespace, "na"}});
+  SymbolInfo("gg", SymbolInfo::SymbolKind::Function, HeaderName, 3,
+ {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
 
-  Symbol = CreateSymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName,
-

[clang-tools-extra] r269427 - [include-fixer] Simplify unittest code.

2016-05-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 13 10:17:17 2016
New Revision: 269427

URL: http://llvm.org/viewvc/llvm-project?rev=269427&view=rev
Log:
[include-fixer] Simplify unittest code.

Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

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

Modified: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp?rev=269427&r1=269426&r2=269427&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp Fri May 13 
10:17:17 2016
@@ -15,24 +15,9 @@ namespace clang {
 namespace include_fixer {
 
 InMemorySymbolIndex::InMemorySymbolIndex(
-const std::map> &LookupTable) {
-  for (const auto &Entry : LookupTable) {
-llvm::StringRef Identifier(Entry.first);
-llvm::SmallVector Names;
-Identifier.split(Names, "::");
-for (const auto &Header : Entry.second) {
-  std::vector Contexts;
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend(); ++IdentiferContext) {
-Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-  *IdentiferContext);
-  }
-
-  SymbolInfo Symbol(Names.back(), SymbolInfo::SymbolKind::Class, Header,
-Contexts, 1);
-  this->LookupTable[Symbol.getName()].push_back(Symbol);
-}
-  }
+const std::vector &Symbols) {
+  for (const auto &Symbol : Symbols)
+LookupTable[Symbol.getName()].push_back(Symbol);
 }
 
 std::vector

Modified: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h?rev=269427&r1=269426&r2=269427&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h Fri May 13 
10:17:17 2016
@@ -21,8 +21,7 @@ namespace include_fixer {
 /// Xref database with fixed content.
 class InMemorySymbolIndex : public SymbolIndex {
 public:
-  InMemorySymbolIndex(
-  const std::map> &LookupTable);
+  InMemorySymbolIndex(const std::vector 
&Symbols);
 
   std::vector
   search(llvm::StringRef Identifier) override;

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=269427&r1=269426&r2=269427&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 13 10:17:17 2016
@@ -92,7 +92,7 @@ llvm::Optional CreateSymbolI
 return llvm::None;
 
   return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
-GetContexts(ND), SM.getExpansionLineNumber(Loc));
+SM.getExpansionLineNumber(Loc), GetContexts(ND));
 }
 
 } // namespace

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=269427&r1=269426&r2=269427&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Fri 
May 13 10:17:17 2016
@@ -70,8 +70,8 @@ namespace clang {
 namespace find_all_symbols {
 
 SymbolInfo::SymbolInfo(llvm::StringRef Name, SymbolKind Type,
-   llvm::StringRef FilePath,
-   const std::vector &Contexts, int LineNumber)
+   llvm::StringRef FilePath, int LineNumber,
+   const std::vector &Contexts)
 : Name(Na

Re: [PATCH] D20232: [include-fixer] Simplify unittest code.

2016-05-13 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269427: [include-fixer] Simplify unittest code. (authored by 
hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20232?vs=57193&id=57194#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20232

Files:
  clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
  clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
  
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
===
--- clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
@@ -15,24 +15,9 @@
 namespace include_fixer {
 
 InMemorySymbolIndex::InMemorySymbolIndex(
-const std::map> &LookupTable) {
-  for (const auto &Entry : LookupTable) {
-llvm::StringRef Identifier(Entry.first);
-llvm::SmallVector Names;
-Identifier.split(Names, "::");
-for (const auto &Header : Entry.second) {
-  std::vector Contexts;
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend(); ++IdentiferContext) {
-Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-  *IdentiferContext);
-  }
-
-  SymbolInfo Symbol(Names.back(), SymbolInfo::SymbolKind::Class, Header,
-Contexts, 1);
-  this->LookupTable[Symbol.getName()].push_back(Symbol);
-}
-  }
+const std::vector &Symbols) {
+  for (const auto &Symbol : Symbols)
+LookupTable[Symbol.getName()].push_back(Symbol);
 }
 
 std::vector
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -62,18 +62,20 @@
 std::map> SymbolsMap;
 SmallVector SemicolonSplits;
 StringRef(Input).split(SemicolonSplits, ";");
+std::vector Symbols;
 for (StringRef Pair : SemicolonSplits) {
   auto Split = Pair.split('=');
   std::vector Headers;
   SmallVector CommaSplits;
   Split.second.split(CommaSplits, ",");
   for (StringRef Header : CommaSplits)
-Headers.push_back(Header.trim());
-  SymbolsMap[Split.first.trim()] = std::move(Headers);
+Symbols.push_back(find_all_symbols::SymbolInfo(
+Split.first.trim(),
+find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1,
+{}));
 }
 SymbolIndexMgr->addSymbolIndex(
-llvm::make_unique(
-std::move(SymbolsMap)));
+llvm::make_unique(Symbols));
 break;
   }
   case yaml: {
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
@@ -92,7 +92,7 @@
 return llvm::None;
 
   return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
-GetContexts(ND), SM.getExpansionLineNumber(Loc));
+SM.getExpansionLineNumber(Loc), GetContexts(ND));
 }
 
 } // namespace
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -70,8 +70,8 @@
 namespace find_all_symbols {
 
 SymbolInfo::SymbolInfo(llvm::StringRef Name, SymbolKind Type,
-   llvm::StringRef FilePath,
-   const std::vector &Contexts, int LineNumber)
+   llvm::StringRef FilePath, int LineNumber,
+   const std::vector &Contexts)
 : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts),
   LineNumber(LineNumber) {}
 
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
@@ -50,7 +50,7 @@
   SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {};
 
   SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm

Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-13 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Hi Richard. Just want to double-check something. If we have no alignment value, 
for this check, can we assume 1?
It seems to me that that shouldn't be a problem, but wanted to double-check.



Comment at: lib/CodeGen/CGExpr.cpp:579
@@ -578,1 +578,3 @@
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {

Would it be acceptable to set AlignVal to 1 if it's 0?


http://reviews.llvm.org/D19667



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


[PATCH] D20240: [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

The build is broken due to a missing dependency.

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Which produce this error:
```
tools/clang/tools/extra/clang-rename/CMakeFiles/clangRename.dir/USRLocFinder.cpp.o:
 In function `clang::RecursiveASTVisitor::TraverseCXXConstructorDecl(clang::CXXConstructorDecl*)':
USRLocFinder.cpp:(.text._ZN5clang19RecursiveASTVisitorINS_6rename12_GLOBAL__N_123USRLocFindingASTVisitorEE26TraverseCXXConstructorDeclEPNS_18CXXConstructorDeclE+0x170):
 undefined reference to `clang::Lexer::getSourceText(clang::CharSourceRange, 
clang::SourceManager const&, clang::LangOptions const&, bool*)'
```

http://reviews.llvm.org/D20240

Files:
  clang-rename/CMakeLists.txt

Index: clang-rename/CMakeLists.txt
===
--- clang-rename/CMakeLists.txt
+++ clang-rename/CMakeLists.txt
@@ -10,6 +10,7 @@
   clangAST
   clangBasic
   clangIndex
+  clangLex
   clangToolingCore
   )
 


Index: clang-rename/CMakeLists.txt
===
--- clang-rename/CMakeLists.txt
+++ clang-rename/CMakeLists.txt
@@ -10,6 +10,7 @@
   clangAST
   clangBasic
   clangIndex
+  clangLex
   clangToolingCore
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20240: [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Yaron Keren via cfe-commits
yaron.keren added a subscriber: yaron.keren.
yaron.keren accepted this revision.
yaron.keren added a reviewer: yaron.keren.
yaron.keren added a comment.
This revision is now accepted and ready to land.

result of r269402,  LGTM


http://reviews.llvm.org/D20240



___
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-13 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 57185.

http://reviews.llvm.org/D20196

Files:
  docs/clang-tidy/checks/performance-inefficient-string-addition.rst

Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- docs/clang-tidy/checks/performance-inefficient-string-addition.rst
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -5,7 +5,7 @@
 
 The problem
 ---
-This check is to warn about the performance overhead arising from 
concatenating strings, using the operator+, for instance:
+This check is to warn about the performance overhead arising from 
concatenating strings, using the ``operator+``, for instance:
 
 .. code:: c++
 


Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- docs/clang-tidy/checks/performance-inefficient-string-addition.rst
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -5,7 +5,7 @@
 
 The problem
 ---
-This check is to warn about the performance overhead arising from concatenating strings, using the operator+, for instance:
+This check is to warn about the performance overhead arising from concatenating strings, using the ``operator+``, for instance:
 
 .. code:: c++
 
___
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-13 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 57181.

http://reviews.llvm.org/D20196

Files:
  docs/clang-tidy/checks/performance-inefficient-string-addition.rst

Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- docs/clang-tidy/checks/performance-inefficient-string-addition.rst
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -12,7 +12,7 @@
 std::string a("Foo"), b("Bar");
 a = a + b;
 
-Instead of this structure you should use `operator+=` or std::string's 
(std::basic_string) class member function `append`. For instance:
+Instead of this structure you should use ``operator+=`` or std::string's 
(std::basic_string) class member function ``append``. For instance:

 .. code:: c++
 


Index: docs/clang-tidy/checks/performance-inefficient-string-addition.rst
===
--- docs/clang-tidy/checks/performance-inefficient-string-addition.rst
+++ docs/clang-tidy/checks/performance-inefficient-string-addition.rst
@@ -12,7 +12,7 @@
 std::string a("Foo"), b("Bar");
 a = a + b;
 
-Instead of this structure you should use `operator+=` or std::string's (std::basic_string) class member function `append`. For instance:
+Instead of this structure you should use ``operator+=`` or std::string's (std::basic_string) class member function ``append``. For instance:

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


Re: [PATCH] D20240: [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

thanks, landing as soon as my other checkouts complete their tests (few 
minutes).


http://reviews.llvm.org/D20240



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


r269419 - [CodeGen] Clang does not choose aapcs-vfp calling convention for ARM bare metal target with hard float (EABIHF)

2016-05-13 Thread Oleg Ranevskyy via cfe-commits
Author: oleg
Date: Fri May 13 09:45:57 2016
New Revision: 269419

URL: http://llvm.org/viewvc/llvm-project?rev=269419&view=rev
Log:
[CodeGen] Clang does not choose aapcs-vfp calling convention for ARM bare metal 
target with hard float (EABIHF)

Summary:
Clang does not detect `aapcs-vfp` for the EABIHF environment. The reason is 
that only GNUEABIHF is considered while choosing calling convention, EABIHF is 
ignored.

This causes clang to use `aapcs` for EABIHF and add the `arm_aapcscc` specifier 
to functions in generated IR.

The modified `arm-cc.c` test checks that no calling convention specifier is 
added to functions for EABIHF, which means the default one is used 
(`CallingConv::ARM_AAPCS_VFP`).

Reviewers: rengolin, compnerd, t.p.northover

Subscribers: aemerson, rengolin, asl, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/arm-cc.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=269419&r1=269418&r2=269419&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 13 09:45:57 2016
@@ -7878,7 +7878,8 @@ const TargetCodeGenInfo &CodeGenModule::
   Kind = ARMABIInfo::AAPCS16_VFP;
 else if (CodeGenOpts.FloatABI == "hard" ||
  (CodeGenOpts.FloatABI != "soft" &&
-  Triple.getEnvironment() == llvm::Triple::GNUEABIHF))
+  (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
+   Triple.getEnvironment() == llvm::Triple::EABIHF)))
   Kind = ARMABIInfo::AAPCS_VFP;
 
 return SetCGInfo(new ARMTargetCodeGenInfo(Types, Kind));

Modified: cfe/trunk/test/CodeGen/arm-cc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-cc.c?rev=269419&r1=269418&r2=269419&view=diff
==
--- cfe/trunk/test/CodeGen/arm-cc.c (original)
+++ cfe/trunk/test/CodeGen/arm-cc.c Fri May 13 09:45:57 2016
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs  -emit-llvm 
-w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu 
-emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s
 // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi aapcs  
-emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-AAPCS %s
+// RUN: %clang_cc1 -triple armv7-none-eabihf -target-abi aapcs-vfp -emit-llvm 
-w -o - %s | FileCheck -check-prefix=BAREMETAL-AAPCS_VFP %s
 
 
 // DARWIN-APCS-LABEL: define void @f()
@@ -13,6 +14,9 @@
 // LINUX-APCS: call arm_apcscc void @g
 // LINUX-AAPCS-LABEL: define void @f()
 // LINUX-AAPCS: call void @g
+// BAREMETAL-AAPCS_VFP-LABEL: define void @f()
+// BAREMETAL-AAPCS_VFP: call void @g
+// BAREMETAL-AAPCS_VFP: declare void @g()
 void g(void);
 void f(void) {
   g();


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


Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread Adrian McCarthy via cfe-commits
amccarth marked 2 inline comments as done.


Comment at: lib/Driver/MSVCToolChain.cpp:42
@@ -40,1 +41,3 @@
+
+  #pragma comment(lib, "version.lib")
 #endif

aaron.ballman wrote:
> Eh, I am lightening up on this sort of thing, so this is fine by me.
I was following the pattern I saw in llvm\lib\Support\Windows\Path.inc (and 
elsewhere), so I thought it was the way we did things around here.


Comment at: lib/Driver/MSVCToolChain.cpp:483
@@ +482,3 @@
+  }
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

aaron.ballman wrote:
> Pure pedantry: `uint8_t` instead of `char`, or is this data really a textual 
> string in practice?
It's a mix.  The part we're looking at is binary data, but the rest of the 
block is text.

I though the API wanted a pointer to char, so I chose `char` to avoid 
unnecessary casts.

But I must've misread the reference page, because just now I double-checked and 
I see that the API wants a void pointer, so I'll go ahead and use `uint8_t`, 
which satisfies my inner pedant as well.


http://reviews.llvm.org/D20136



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


Re: [PATCH] D20205: [include-fixer] Use scope contexts information to improve query.

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

Rebase.


http://reviews.llvm.org/D20205

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndexManager.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -59,6 +59,9 @@
   SymbolInfo("foo", SymbolInfo::SymbolKind::Class, "\"dir/otherdir/qux.h\"",
  1, {{SymbolInfo::ContextType::Namespace, "b"},
  {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
+ 1, {{SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -137,6 +140,20 @@
 runIncludeFixer("std::string bar;\nstd::sting foo;\n"));
 }
 
+TEST(IncludeFixer, ScopedNamespaceSymbols) {
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { b::bar b; }\n",
+runIncludeFixer("namespace a { b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { a::b::bar b; }\n",
+runIncludeFixer("namespace A { a::b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { void func() { b::bar b; } }\n",
+runIncludeFixer("namespace a { void func() { b::bar b; } }\n"));
+  EXPECT_EQ("namespace A { c::b::bar b; }\n",
+runIncludeFixer("namespace A { c::b::bar b; }\n"));
+  // FIXME: The header should not be added here. Remove this after we support
+  // full match.
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
+runIncludeFixer("namespace A { b::bar b; }\n"));
+}
 } // namespace
 } // namespace include_fixer
 } // namespace clang
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -39,18 +39,20 @@
 if (Symbol.getName() == Names.back()) {
   bool IsMatched = true;
   auto SymbolContext = Symbol.getContexts().begin();
+  auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend() &&
-   SymbolContext != Symbol.getContexts().end();
+  for (; IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end();
++IdentiferContext, ++SymbolContext) {
 if (SymbolContext->second != *IdentiferContext) {
   IsMatched = false;
   break;
 }
   }
 
-  if (IsMatched) {
+  // FIXME: Support full match. At this point, we only find symbols in
+  // database which end with the same contexts with the identifier.
+  if (IsMatched && IdentiferContext == Names.rend()) {
 // FIXME: file path should never be in the form of <...> or "...", but
 // the unit test with fixed database use <...> file path, which might
 // need to be changed.
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -116,6 +116,19 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+std::string TypoScopeString;
+if (S) {
+  // FIXME: Currently we only use namespace contexts. Use other context
+  // types for query.
+  for (const auto *Context = S->getEntity(); Context;
+   Context = Context->getParent()) {
+if (const auto *ND = dyn_cast(Context)) {
+  if (!ND->getName().empty())
+TypoScopeString = ND->getNameAsString() + "::" + TypoScopeString;
+}
+  }
+}
+
 /// If we have a scope specification, use that to get more precise results.
 std::string QueryString;
 if (SS && SS->getRange().isValid()) {
@@ -150,7 +163,23 @@
   QueryString = Typo.getAsString();
 }
 
-return query(QueryString, Typo.getLoc());
+// Follow C++ Lookup rules. Firstly, lookup the identifier with scoped
+// namespace contexts. If fails, falls back to identifier.
+// For example:
+//
+// namespace a {
+// b::foo f;
+// }
+//
+// 1. lookup a::b::foo.
+// 2. lookup b::foo.
+if (!query(TypoScopeString + QueryString, Typo.getLoc()))
+  query(QueryString, Typo.getLoc());
+
+// FIXME: We should just return the name we got as input here and prevent
+// clang from trying to correct the typo by itself. That may change the
+// identifier to something that's not wanted by the user.
+return clang::TypoCorrection();
   }
 
   StringRef filename() const { return F

Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread Adrian McCarthy via cfe-commits
amccarth updated this revision to Diff 57196.
amccarth marked an inline comment as done.
amccarth added a comment.

Addressed additional comments.


http://reviews.llvm.org/D20136

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/cl-options.c
  test/Driver/msc-version.c
  test/Driver/msvc-triple.c
  test/Misc/diag-format.c

Index: test/Misc/diag-format.c
===
--- test/Misc/diag-format.c
+++ test/Misc/diag-format.c
@@ -37,7 +37,7 @@
 // DEFAULT: {{.*}}:36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
 // MSVC2010: {{.*}}(36,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
 // MSVC2013: {{.*}}(36,8) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// MSVC: {{.*}}(36,8) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC: {{.*}}(36,8){{ ?}}: warning: extra tokens at end of #endif directive [-Wextra-tokens]
 // MSVC2015: {{.*}}(36,8): warning: extra tokens at end of #endif directive [-Wextra-tokens]
 // VI: {{.*}} +36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
 // MSVC2015_ORIG: {{.*}}(36): warning: extra tokens at end of #endif directive [-Wextra-tokens]
Index: test/Driver/msvc-triple.c
===
--- test/Driver/msvc-triple.c
+++ test/Driver/msvc-triple.c
@@ -1,9 +1,7 @@
-// RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
 // RUN: %clang -target i686-pc-windows-msvc19 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=TARGET-19
 // RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - -fms-compatibility-version=19 | FileCheck %s --check-prefix=OVERRIDE-19
 // RUN: %clang -target i686-pc-windows-msvc-elf -S -emit-llvm %s -o - | FileCheck %s --check-prefix=ELF-DEFAULT
 
-// DEFAULT: target triple = "i686-pc-windows-msvc18.0.0"
 // TARGET-19:   target triple = "i686-pc-windows-msvc19.0.0"
 // OVERRIDE-19: target triple = "i686-pc-windows-msvc19.0.0"
-// ELF-DEFAULT: target triple = "i686-pc-windows-msvc18.0.0-elf"
+// ELF-DEFAULT: target triple = "i686-pc-windows-msvc{{.*}}-elf"
Index: test/Driver/msc-version.c
===
--- test/Driver/msc-version.c
+++ test/Driver/msc-version.c
@@ -1,15 +1,4 @@
 //
-// Verify defaults
-//
-
-// RUN: %clang -target i686-windows -fms-compatibility -dM -E - &1 | FileCheck -check-prefix=NoThreadSafeStatics %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
 // NoThreadSafeStatics: "-fno-threadsafe-statics"
 
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -682,7 +682,8 @@
 
 /// Visual studio tools.
 namespace visualstudio {
-VersionTuple getMSVCVersion(const Driver *D, const llvm::Triple &Triple,
+VersionTuple getMSVCVersion(const Driver *D, const ToolChain &TC,
+const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args, bool IsWindowsMSVC);
 
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3291,7 +3291,7 @@
   Result.append(UID.begin(), UID.end());
 }
 
-VersionTuple visualstudio::getMSVCVersion(const Driver *D,
+VersionTuple visualstudio::getMSVCVersion(const Driver *D, const ToolChain &TC,
   const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
   bool IsWindowsMSVC) {
@@ -,8 +,14 @@
 if (Major || Minor || Micro)
   return VersionTuple(Major, Minor, Micro);
 
-// FIXME: Consider bumping this to 19 (MSVC2015) soon.
-return VersionTuple(18);
+if (IsWindowsMSVC) {
+  VersionTuple MSVT = TC.getMSVCVersionFromExe();
+  if (!MSVT.empty())
+return MSVT;
+
+  // FIXME: Consider bumping this to 19 (MSVC2015) soon.
+  return VersionTuple(18);
+}
   }
   return VersionTuple();
 }
@@ -5224,7 +5230,7 @@
 
   // -fms-compatibility-version=18.00 is default.
   VersionTuple MSVT = visualstudio::getMSVCVersion(
-  &D, getToolChain().getTriple(), Args, IsWindowsMSVC);
+  &D, getToolChain(), getToolChain().getTriple(), Args, IsWindowsMSVC);
   if (!MSVT.empty())
 CmdArgs.push_back(
 Args.MakeArgString("-fms-compatibility-version=" + MSVT.getAsString()));
Index: lib/Driver/ToolChains.h
==

[clang-tools-extra] r269429 - [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Fri May 13 10:38:54 2016
New Revision: 269429

URL: http://llvm.org/viewvc/llvm-project?rev=269429&view=rev
Log:
[clang-rename] Fix broken dependency on shared build.

Summary:
The build is broken due to a missing dependency.

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Which produce this error:
```
tools/clang/tools/extra/clang-rename/CMakeFiles/clangRename.dir/USRLocFinder.cpp.o:
 In function `clang::RecursiveASTVisitor::TraverseCXXConstructorDecl(clang::CXXConstructorDecl*)':
USRLocFinder.cpp:(.text._ZN5clang19RecursiveASTVisitorINS_6rename12_GLOBAL__N_123USRLocFindingASTVisitorEE26TraverseCXXConstructorDeclEPNS_18CXXConstructorDeclE+0x170):
 undefined reference to `clang::Lexer::getSourceText(clang::CharSourceRange, 
clang::SourceManager const&, clang::LangOptions const&, bool*)'
```

Reviewers: alexfh, yaron.keren

Subscribers: yaron.keren, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-rename/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-rename/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/CMakeLists.txt?rev=269429&r1=269428&r2=269429&view=diff
==
--- clang-tools-extra/trunk/clang-rename/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-rename/CMakeLists.txt Fri May 13 10:38:54 2016
@@ -10,6 +10,7 @@ add_clang_library(clangRename
   clangAST
   clangBasic
   clangIndex
+  clangLex
   clangToolingCore
   )
 


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


[clang-tools-extra] r269430 - [include-fixer] Use scope contexts information to improve query.

2016-05-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 13 10:44:16 2016
New Revision: 269430

URL: http://llvm.org/viewvc/llvm-project?rev=269430&view=rev
Log:
[include-fixer] Use scope contexts information to improve query.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=269430&r1=269429&r2=269430&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri May 13 10:44:16 
2016
@@ -116,6 +116,19 @@ public:
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+std::string TypoScopeString;
+if (S) {
+  // FIXME: Currently we only use namespace contexts. Use other context
+  // types for query.
+  for (const auto *Context = S->getEntity(); Context;
+   Context = Context->getParent()) {
+if (const auto *ND = dyn_cast(Context)) {
+  if (!ND->getName().empty())
+TypoScopeString = ND->getNameAsString() + "::" + TypoScopeString;
+}
+  }
+}
+
 /// If we have a scope specification, use that to get more precise results.
 std::string QueryString;
 if (SS && SS->getRange().isValid()) {
@@ -150,7 +163,23 @@ public:
   QueryString = Typo.getAsString();
 }
 
-return query(QueryString, Typo.getLoc());
+// Follow C++ Lookup rules. Firstly, lookup the identifier with scoped
+// namespace contexts. If fails, falls back to identifier.
+// For example:
+//
+// namespace a {
+// b::foo f;
+// }
+//
+// 1. lookup a::b::foo.
+// 2. lookup b::foo.
+if (!query(TypoScopeString + QueryString, Typo.getLoc()))
+  query(QueryString, Typo.getLoc());
+
+// FIXME: We should just return the name we got as input here and prevent
+// clang from trying to correct the typo by itself. That may change the
+// identifier to something that's not wanted by the user.
+return clang::TypoCorrection();
   }
 
   StringRef filename() const { return Filename; }
@@ -235,12 +264,12 @@ public:
 
 private:
   /// Query the database for a given identifier.
-  clang::TypoCorrection query(StringRef Query, SourceLocation Loc) {
+  bool query(StringRef Query, SourceLocation Loc) {
 assert(!Query.empty() && "Empty query!");
 
 // Save database lookups by not looking up identifiers multiple times.
 if (!SeenQueries.insert(Query).second)
-  return clang::TypoCorrection();
+  return true;
 
 DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
 DEBUG(Loc.print(llvm::dbgs(), getCompilerInstance().getSourceManager()));
@@ -250,16 +279,13 @@ private:
 auto SearchReply = SymbolIndexMgr.search(Query);
 DEBUG(llvm::dbgs() << SearchReply.size() << " replies\n");
 if (SearchReply.empty())
-  return clang::TypoCorrection();
+  return false;
 
 // Add those files to the set of includes to try out.
 // FIXME: Rank the results and pick the best one instead of the first one.
 TryInclude(Query, SearchReply[0]);
 
-// FIXME: We should just return the name we got as input here and prevent
-// clang from trying to correct the typo by itself. That may change the
-// identifier to something that's not wanted by the user.
-return clang::TypoCorrection();
+return true;
   }
 
   /// The client to use to find cross-references.

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=269430&r1=269429&r2=269430&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Fri May 13 
10:44:16 2016
@@ -39,10 +39,10 @@ SymbolIndexManager::search(llvm::StringR
 if (Symbol.getName() == Names.back()) {
   bool IsMatched = true;
   auto SymbolContext = Symbol.getContexts().begin();
+  auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend() &&
-   SymbolContext != Symbol.getContexts().end();
+  for (; IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end();
++IdentiferContext, ++SymbolContext) {
 if (SymbolContext->second != *Identi

Re: [PATCH] D20205: [include-fixer] Use scope contexts information to improve query.

2016-05-13 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269430: [include-fixer] Use scope contexts information to 
improve query. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20205?vs=57197&id=57200#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20205

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -59,6 +59,9 @@
   SymbolInfo("foo", SymbolInfo::SymbolKind::Class, "\"dir/otherdir/qux.h\"",
  1, {{SymbolInfo::ContextType::Namespace, "b"},
  {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
+ 1, {{SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -137,6 +140,20 @@
 runIncludeFixer("std::string bar;\nstd::sting foo;\n"));
 }
 
+TEST(IncludeFixer, ScopedNamespaceSymbols) {
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { b::bar b; }\n",
+runIncludeFixer("namespace a { b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { a::b::bar b; }\n",
+runIncludeFixer("namespace A { a::b::bar b; }\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a { void func() { b::bar b; } }\n",
+runIncludeFixer("namespace a { void func() { b::bar b; } }\n"));
+  EXPECT_EQ("namespace A { c::b::bar b; }\n",
+runIncludeFixer("namespace A { c::b::bar b; }\n"));
+  // FIXME: The header should not be added here. Remove this after we support
+  // full match.
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
+runIncludeFixer("namespace A { b::bar b; }\n"));
+}
 } // namespace
 } // namespace include_fixer
 } // namespace clang
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -39,18 +39,20 @@
 if (Symbol.getName() == Names.back()) {
   bool IsMatched = true;
   auto SymbolContext = Symbol.getContexts().begin();
+  auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (auto IdentiferContext = Names.rbegin() + 1;
-   IdentiferContext != Names.rend() &&
-   SymbolContext != Symbol.getContexts().end();
+  for (; IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end();
++IdentiferContext, ++SymbolContext) {
 if (SymbolContext->second != *IdentiferContext) {
   IsMatched = false;
   break;
 }
   }
 
-  if (IsMatched) {
+  // FIXME: Support full match. At this point, we only find symbols in
+  // database which end with the same contexts with the identifier.
+  if (IsMatched && IdentiferContext == Names.rend()) {
 // FIXME: file path should never be in the form of <...> or "...", but
 // the unit test with fixed database use <...> file path, which might
 // need to be changed.
Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -116,6 +116,19 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+std::string TypoScopeString;
+if (S) {
+  // FIXME: Currently we only use namespace contexts. Use other context
+  // types for query.
+  for (const auto *Context = S->getEntity(); Context;
+   Context = Context->getParent()) {
+if (const auto *ND = dyn_cast(Context)) {
+  if (!ND->getName().empty())
+TypoScopeString = ND->getNameAsString() + "::" + TypoScopeString;
+}
+  }
+}
+
 /// If we have a scope specification, use that to get more precise results.
 std::string QueryString;
 if (SS && SS->getRange().isValid()) {
@@ -150,7 +163,23 @@
   QueryString = Typo.getAsString();
 }
 
-return query(QueryString, Typo.getLoc());
+// Follow C++ Lookup rules. Firstly, lookup the identifier with scoped
+// namespace contexts. If fails, falls back to identifier.
+// For example:
+//
+// namespace a 

r269431 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 13 10:44:37 2016
New Revision: 269431

URL: http://llvm.org/viewvc/llvm-project?rev=269431&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.

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=269431&r1=269430&r2=269431&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13 10:44:37 
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=269431&r1=269430&r2=269431&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 13 10:44:37 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/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=269431&r1=269430&r2=269431&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Fri May 13 10:44:37 2016
@@ -11,25 +11,67 @@
 //
 
//===--===//
 
+// Macro OPENCLEXT or OPENCLEXT_INTERNAL can be defined to enumerate the
+// OpenCL extensions listed in this file.
+//
+// If the extensions are to be enumerated without the supported OpenCL version,
+// define OPENCLEXT(ext) where ext is the name of the extension.
+//
+// If the extensions are to be enumerated with supported OpenCL version,
+// define OPENCLEXT_INTERNAL(ext, avail, core) where
+//   ext - name of the extension or optional core feature.
+//   avail - minimum OpenCL version supporting it.
+//   core - minimum OpenCL version when the extension becomes optional core
+//  feature or core feature. ~0U indicates not a core feature or an
+//  optional core feature.
+
+#ifndef OPENCLEXT_INTERNAL
+#ifndef OPENCLEXT
+#pragma error "macro OPENCLE

Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269431: [OpenCL] Add supported OpenCL extensions to target 
info. (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D19484?vs=57177&id=57201#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19484

Files:
  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/OpenCLOptions.h
  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/extension-fp64-cl1.1.cl
  cfe/trunk/test/SemaOpenCL/extension-fp64.cl
  cfe/trunk/test/SemaOpenCL/extensions.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
  cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
  cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl

Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -207,8 +207,14 @@
 addImplicitTypedef("size_t", Context.getSizeType());
   }
 
-  // Initialize predefined OpenCL types.
+  // Initialize predefined OpenCL types and supported optional core features.
   if (getLangOpts().OpenCL) {
+#define OPENCLEXT(Ext) \
+ if (Context.getTargetInfo().getSupportedOpenCLOpts().is_##Ext##_supported_core( \
+ getLangOpts().OpenCLVersion)) \
+   getOpenCLOptions().Ext = 1;
+#include "clang/Basic/OpenCLExtensions.def"
+
 addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
 addImplicitTypedef("event_t", Context.OCLEventTy);
 if (getLangOpts().OpenCLVersion >= 200) {
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1999,17 +1999,6 @@
   Builder.defineMacro("__HAS_FMAF__");
 if (hasLDEXPF)
   Builder.defineMacro("__HAS_LDEXPF__");
-if (hasFP64 && Opts.OpenCL)
-  Builder.defineMacro("cl_khr_fp64");
-if (Opts.OpenCL) {
-  if (GPU >= GK_NORTHERN_ISLANDS) {
-Builder.defineMacro("cl_khr_byte_addressable_store");
-Builder.defineMacro("cl_khr_global_int32_base_atomics");
-Builder.defineMacro("cl_khr_global_int32_extended_atomics");
-Builder.defineMacro("cl_khr_local_int32_base_atomics");
-Builder.defineMacro("cl_khr_local_int32_extended_atomics");
-  }
-}
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
@@ -2097,6 +2086,31 @@
 
 return true;
   }
+
+   void setSupportedOpenCLOpts() {
+ auto &Opts = getSupportedOpenCLOpts();
+ Opts.cl_clang_storage_class_specifiers = 1;
+ Opts.cl_khr_gl_sharing = 1;
+ Opts.cl_khr_gl_event = 1;
+ Opts.cl_khr_d3d10_sharing = 1;
+ Opts.cl_khr_subgroups = 1;
+
+ if (hasFP64)
+   Opts.cl_khr_fp64 = 1;
+ if (GPU >= GK_NORTHERN_ISLANDS) {
+   Opts.cl_khr_byte_addressable_store = 1;
+   Opts.cl_khr_global_int32_base_atomics = 1;
+   Opts.cl_khr_global_int32_extended_atomics = 1;
+   Opts.cl_khr_local_int32_base_atomics = 1;
+   Opts.cl_khr_local_int32_extended_atomics = 1;
+ }
+ if (GPU >= GK_SOUTHERN_ISLANDS)
+   Opts.cl_khr_fp16 = 1;
+   Opts.cl_khr_int64_base_atomics = 1;
+   Opts.cl_khr_int64_extended_atomics = 1;
+   Opts.cl_khr_3d_image_writes = 1;
+   Opts.cl_khr_gl_msaa_sharing = 1;
+  }
 };
 
 const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = {
@@ -2716,6 +2730,10 @@
   bool hasSjLjLowering() const override {
 return true;
   }
+
+  void setSupportedOpenCLOpts() {
+getSupportedOpenCLOpts().setAll();
+  }
 };
 
 bool X86TargetInfo::setFPMath(StringRef Name) {
@@ -7858,6 +7876,12 @@
   CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
 return CC_SpirFunction;
   }
+
+  void setSupportedOpenCLOpts() {
+// Assume all OpenCL extensions and optional core features are supported
+// for SPIR since it is a generic target.
+getSupportedOpenCLOpts().setAll();
+  }
 };
 
 class SPIR32TargetInfo : public SPIRTargetInfo {
@@ -8458,5 +8482,7 @@
   if (!Target->handleTargetFeatures(Opts->Features, Diags))
 return nullptr;
 

Re: [PATCH] D20157: Add test for D20156

2016-05-13 Thread Diana Picus via cfe-commits
rovka abandoned this revision.
rovka added a comment.

With the new diagnostic handler in r269428, we no longer need this test (it 
will be covered by the existing tests such as 
CodeGen/AArch64/arm64-inline-asm-error-N.ll, by removing the -exit-on-error 
flag).


http://reviews.llvm.org/D20157



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


Re: [PATCH] D20194: [ModuleMap][CrashReproducer] Collect headers from inner frameworks

2016-05-13 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

Let's move the code looks up the alternate name out of the ModuleMap parser, 
and into the dependency collector callbacks.  This feels like an implementation 
detail of the dependency collector.  We could add a new callback specifically 
for umbrella headers and handle this inside there.


http://reviews.llvm.org/D20194



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


[PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

2016-05-13 Thread pierre gousseau via cfe-commits
pgousseau created this revision.
pgousseau added a reviewer: rsmith.
pgousseau added a subscriber: cfe-commits.

On Linux, if a header file included in the pch is modified then a fatal error 
is emitted, which is reasonable.
On Windows the check is ifdefed out, allowing the compilation to continue in a 
broken state.
This leads to "#pragma once" directives to be ignored.
This change disables the inclusion of timestamps in pch files on Windows, for 
now.

http://reviews.llvm.org/D20243

Files:
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/PCH/Inputs/pragma-once2-pch.h
  test/PCH/Inputs/pragma-once2.h
  test/PCH/touch-pragma-once.cpp

Index: test/PCH/touch-pragma-once.cpp
===
--- /dev/null
+++ test/PCH/touch-pragma-once.cpp
@@ -0,0 +1,23 @@
+// On Windows, timestamps for pch are not handled correctly.
+// This would cause pragma once to be ignored on distributed builds.
+// pragma-once2-pch.h includes pragma-once2.h which has a pragma once 
directive.
+// pragma-once2.h is then touched before using the generated pch.
+// On Linux this will cause an expected error, but on Windows we want to
+// ignore the timestamp as the timestamp handling on Windows is
+// inconsistent at the moment.
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify 
%s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h
+// RUN: touch %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// REQUIRES: system-windows
+
+// expected-no-diagnostics
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
\ No newline at end of file
Index: test/PCH/Inputs/pragma-once2.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2.h
@@ -0,0 +1,3 @@
+#pragma once
+
+inline void f() {}
\ No newline at end of file
Index: test/PCH/Inputs/pragma-once2-pch.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once2-pch.h
@@ -0,0 +1 @@
+#include "pragma-once2.h"
\ No newline at end of file
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2013,6 +2013,8 @@
// In our regression testing, the Windows file system seems to
// have inconsistent modification times that sometimes
// erroneously trigger this error-handling path.
+   // For now timestamps are disabled for pch files on Windows (c.f
+   // GeneratePCHAction::CreateASTConsumer).
//
// FIXME: This probably also breaks HeaderFileInfo lookups on Windows.
(StoredTime && StoredTime != File->getModificationTime() &&
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -90,9 +90,15 @@
 
   auto Buffer = std::make_shared();
   std::vector> Consumers;
+  // FIXME: There is a known issue with timestamps appearing to be inconsistent
+  // on Windows (c.f. ASTReader::getInputFile) so we disable timestamps checks
+  // on Windows for now.
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
   Consumers.push_back(llvm::make_unique(
 CI.getPreprocessor(), OutputFile, nullptr, Sysroot,
-Buffer, CI.getFrontendOpts().ModuleFileExtensions));
+Buffer, CI.getFrontendOpts().ModuleFileExtensions,
+/*AllowASTWithErrors*/false,
+/*IncludeTimestamps*/!HostTriple.isOSWindows()));
   Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
   CI, InFile, OutputFile, OS, Buffer));
 


Index: test/PCH/touch-pragma-once.cpp
===
--- /dev/null
+++ test/PCH/touch-pragma-once.cpp
@@ -0,0 +1,23 @@
+// On Windows, timestamps for pch are not handled correctly.
+// This would cause pragma once to be ignored on distributed builds.
+// pragma-once2-pch.h includes pragma-once2.h which has a pragma once directive.
+// pragma-once2.h is then touched before using the generated pch.
+// On Linux this will cause an expected error, but on Windows we want to
+// ignore the timestamp as the timestamp handling on Windows is
+// inconsistent at the moment.
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h
+// RUN: touch %S/Inputs/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// REQUIRES: system-windows
+
+// expected-no-diagnostics
+
+#include "Inputs/pragma-once2.h"
+
+void g() { f(); }
\ No newline at en

RE: r269411 - [mips] Consult triple's vendor field before using musl's interpreter.

2016-05-13 Thread Daniel Sanders via cfe-commits
Hi,

This change makes sense but it needs a test case.

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Vasileios Kalintiris via cfe-commits
> Sent: 13 May 2016 13:13
> To: cfe-commits@lists.llvm.org
> Subject: r269411 - [mips] Consult triple's vendor field before using musl's
> interpreter.
> 
> Author: vkalintiris
> Date: Fri May 13 07:13:13 2016
> New Revision: 269411
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269411&view=rev
> Log:
> [mips] Consult triple's vendor field before using musl's interpreter.
> 
> This should affect only the mips-mti-linux toolchain.
> 
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> 
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Driver/Tools.cpp?rev=269411&r1=269410&r2=269411&
> view=diff
> ==
> 
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri May 13 07:13:13 2016
> @@ -8991,7 +8991,9 @@ static std::string getLinuxDynamicLinker
>  bool IsNaN2008 = mips::isNaN2008(Args, ToolChain.getTriple());
>  if (mips::isUCLibc(Args))
>LibName = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
> -else if (!ToolChain.getTriple().hasEnvironment()) {
> +else if (!ToolChain.getTriple().hasEnvironment() &&
> + ToolChain.getTriple().getVendor() ==
> + llvm::Triple::VendorType::MipsTechnologies) {
>bool LE = (ToolChain.getTriple().getArch() == llvm::Triple::mipsel) ||
>  (ToolChain.getTriple().getArch() == llvm::Triple::mips64el);
>LibName = LE ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be updated and restarted tonight

2016-05-13 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


[patch] Don't use appending linkage for embeded bitcode

2016-05-13 Thread Rafael Espíndola via cfe-commits
Hi Steven,

I think there was a mistake when picking this linkage. The appending
linkage is really just for things that llvm itself special cases. By
an historical artifact it was codegened just like external.

The attached patch changes it to external linkage. I tested that the
produced .o file is bit by bit identical with this change.

But I have to ask, what is the intended use? I was under the
impression that the idea was to allow multiple .o files to have their
IR embedded and have the liker concatenate them.

Currently, with or without this patch, I expect you to get a
duplicated symbol error. To implement the above the symbol should be
internal end the GV added to llvm.used.

Cheers,
Rafael
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index bffa621..4f0a3ca 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/lib/CodeGen/BackendUtil.cpp
@@ -820,9 +820,8 @@ void clang::EmbedBitcode(llvm::Module *M, const 
CodeGenOptions &CGOpts,
   }
   llvm::Constant *ModuleConstant =
   llvm::ConstantDataArray::get(M->getContext(), ModuleData);
-  // Use Appending linkage so it doesn't get optimized out.
   llvm::GlobalVariable *GV = new llvm::GlobalVariable(
-  *M, ModuleConstant->getType(), true, llvm::GlobalValue::AppendingLinkage,
+  *M, ModuleConstant->getType(), true, llvm::GlobalValue::ExternalLinkage,
   ModuleConstant);
   GV->setSection(getSectionNameForBitcode(T));
   if (llvm::GlobalVariable *Old =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [patch] Don't use appending linkage for embeded bitcode

2016-05-13 Thread Steven Wu via cfe-commits
Hi Rafael

Thanks for notice this! That would definitely cause duplicated symbol error and 
I should definitely change that. 
Here is some background:
ld64 in Xcode 7+ knows how to handle the embedded bitcode correctly but not the 
ones in earlier Xcode. The old ld64 will simply concatenate the bitcode files 
which is not the right thing to do. So there is a symbol generated at the place 
to prevent user to link the bitcode object file with old ld64 because older 
ld64 will fail and report duplicated symbols.
I have a radar tracking to change the linkage type when upstream but I dropped 
the ball on that one. The correct thing to do is to make it internal and add to 
llvm.used. I will come up with a patch.

Steven

> On May 13, 2016, at 9:46 AM, Rafael Espíndola  
> wrote:
> 
> Hi Steven,
> 
> I think there was a mistake when picking this linkage. The appending
> linkage is really just for things that llvm itself special cases. By
> an historical artifact it was codegened just like external.
> 
> The attached patch changes it to external linkage. I tested that the
> produced .o file is bit by bit identical with this change.
> 
> But I have to ask, what is the intended use? I was under the
> impression that the idea was to allow multiple .o files to have their
> IR embedded and have the liker concatenate them.
> 
> Currently, with or without this patch, I expect you to get a
> duplicated symbol error. To implement the above the symbol should be
> internal end the GV added to llvm.used.
> 
> Cheers,
> Rafael
> 

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


[PATCH] D20245: [include-fixer] Fix broken dependency shared build

2016-05-13 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: bkramer, hokein.
etienneb added a subscriber: cfe-commits.

The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o:
 In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): 
undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o:
 In function `clang::include_fixer::(anonymous 
namespace)::runIncludeFixer(llvm::StringRef, std::vector > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
```

http://reviews.llvm.org/D20245

Files:
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/tool/CMakeLists.txt
  unittests/include-fixer/CMakeLists.txt

Index: unittests/include-fixer/CMakeLists.txt
===
--- unittests/include-fixer/CMakeLists.txt
+++ unittests/include-fixer/CMakeLists.txt
@@ -22,6 +22,7 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(find-all-symbols)
Index: include-fixer/tool/CMakeLists.txt
===
--- include-fixer/tool/CMakeLists.txt
+++ include-fixer/tool/CMakeLists.txt
@@ -8,4 +8,5 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.h
@@ -47,7 +47,7 @@
 
   // The default constructor is required by YAML traits in
   // LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.
-  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {};
+  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {}
 
   SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
  int LineNumber, const std::vector &Contexts);


Index: unittests/include-fixer/CMakeLists.txt
===
--- unittests/include-fixer/CMakeLists.txt
+++ unittests/include-fixer/CMakeLists.txt
@@ -22,6 +22,7 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(find-all-symbols)
Index: include-fixer/tool/CMakeLists.txt
===
--- include-fixer/tool/CMakeLists.txt
+++ include-fixer/tool/CMakeLists.txt
@@ -8,4 +8,5 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.h
@@ -47,7 +47,7 @@
 
   // The default constructor is required by YAML traits in
   // LLVM_YAML_IS_DOCUMENT_LIST_V

Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Jun Bum Lim via cfe-commits
junbuml added a subscriber: junbuml.
junbuml added a comment.

In current trunk, I got build error :

  llvm/tools/clang/lib/Basic/Targets.cpp:2090:9: error: 
'setSupportedOpenCLOpts' overrides a member function but is not marked 
'override' [-Werror,-Winconsistent-missing-override]
   void setSupportedOpenCLOpts() {

Can you revert this change if this error is related with this change ?


Repository:
  rL LLVM

http://reviews.llvm.org/D19484



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


Re: [patch] Don't use appending linkage for embeded bitcode

2016-05-13 Thread Rafael Espíndola via cfe-commits
On 13 May 2016 at 13:02, Steven Wu  wrote:
> Hi Rafael
>
> Thanks for notice this! That would definitely cause duplicated symbol error 
> and I should definitely change that.
> Here is some background:
> ld64 in Xcode 7+ knows how to handle the embedded bitcode correctly but not 
> the ones in earlier Xcode. The old ld64 will simply concatenate the bitcode 
> files which is not the right thing to do. So there is a symbol generated at 
> the place to prevent user to link the bitcode object file with old ld64 
> because older ld64 will fail and report duplicated symbols.
> I have a radar tracking to change the linkage type when upstream but I 
> dropped the ball on that one. The correct thing to do is to make it internal 
> and add to llvm.used. I will come up with a patch.

Thank you so much!

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


r269435 - Revert "[OpenCL] Add supported OpenCL extensions to target info."

2016-05-13 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 13 12:16:26 2016
New Revision: 269435

URL: http://llvm.org/viewvc/llvm-project?rev=269435&view=rev
Log:
Revert "[OpenCL] Add supported OpenCL extensions to target info."

Revert r269431 due to build failure caused by warning msg:

  llvm/tools/clang/lib/Basic/Targets.cpp:2090:9: error: 
'setSupportedOpenCLOpts' overrides a member function but is not marked 
'override' [-Werror,-Winconsistent-missing-override]
   void setSupportedOpenCLOpts() {


Added:
cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
  - copied unchanged from r269430, 
cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
cfe/trunk/test/SemaOpenCL/extension-fp64.cl
  - copied unchanged from r269430, 
cfe/trunk/test/SemaOpenCL/extension-fp64.cl
cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
  - copied unchanged from r269430, 
cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
  - copied unchanged from r269430, 
cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
Removed:
cfe/trunk/include/clang/Basic/OpenCLOptions.h
cfe/trunk/test/SemaOpenCL/extensions.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=269435&r1=269434&r2=269435&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13 12:16:26 
2016
@@ -926,10 +926,6 @@ 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=269435&r1=269434&r2=269435&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 13 12:16:26 2016
@@ -160,6 +160,18 @@ 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/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=269435&r1=269434&r2=269435&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Fri May 13 12:16:26 2016
@@ -11,67 +11,25 @@
 //
 
//===--===//
 
-// Macro OPENCLEXT or OPENCLEXT_INTERNAL can be defined to enumerate the
-// OpenCL extensions listed in this file.
-//
-// If the extensions are to be enumerated without the supported OpenCL version,
-// define OPENCLEXT(ext) where ext is the name of the extension.
-//
-// If the extensions are to be enumerated with supported OpenCL version,
-// define OPENCLEXT_INTERNA

RE: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-13 Thread Liu, Yaxun (Sam) via cfe-commits
Done. Thanks for letting me know.

Sam

-Original Message-
From: Jun Bum Lim [mailto:junb...@codeaurora.org] 
Sent: Friday, May 13, 2016 1:10 PM
To: Liu, Yaxun (Sam) ; anastasia.stul...@arm.com; 
aleksey.ba...@mail.ru
Cc: junb...@codeaurora.org; Stellard, Thomas ; 
xiuli...@outlook.com; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target 
info.

junbuml added a subscriber: junbuml.
junbuml added a comment.

In current trunk, I got build error :

  llvm/tools/clang/lib/Basic/Targets.cpp:2090:9: error: 
'setSupportedOpenCLOpts' overrides a member function but is not marked 
'override' [-Werror,-Winconsistent-missing-override]
   void setSupportedOpenCLOpts() {

Can you revert this change if this error is related with this change ?


Repository:
  rL LLVM

http://reviews.llvm.org/D19484



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


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

2016-05-13 Thread Steven Wu via cfe-commits
Hi Yaxun

You seems missing some override keyword that triggers 
-Winconsistent-missing-override. See:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/24442/warnings8Result/new/

Here is a patch to fix them:

diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index b1b12e4..20f1e95 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -2087,7 +2087,7 @@ public:
 return true;
   }
 
-   void setSupportedOpenCLOpts() {
+   void setSupportedOpenCLOpts() override {
  auto &Opts = getSupportedOpenCLOpts();
  Opts.cl_clang_storage_class_specifiers = 1;
  Opts.cl_khr_gl_sharing = 1;
@@ -2731,7 +2731,7 @@ public:
 return true;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 getSupportedOpenCLOpts().setAll();
   }
 };
@@ -7877,7 +7877,7 @@ public:
 return CC_SpirFunction;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 // Assume all OpenCL extensions and optional core features are supported
 // for SPIR since it is a generic target.
 getSupportedOpenCLOpts().setAll();

Thanks

Steven

> On May 13, 2016, at 8:44 AM, Yaxun Liu via cfe-commits 
>  wrote:
> 
> Author: yaxunl
> Date: Fri May 13 10:44:37 2016
> New Revision: 269431
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269431&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.
> 
> 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=269431&r1=269430&r2=269431&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13 10:44:37 
> 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=269431&r1=269430&r2=269431&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 13 10:44:37 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 {
>   /// \

Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/Driver/MSVCToolChain.cpp:481
@@ +480,3 @@
+
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

It might be nicer to use a `SmallVector`, or 
whatever `VersionSize` typically is, here to avoid heap allocation in the 
common case.


http://reviews.llvm.org/D20136



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


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

2016-05-13 Thread Liu, Yaxun (Sam) via cfe-commits
Thanks Steven.

I have reverted my change. I will apply your patch and re-commit.

Sam

-Original Message-
From: steve...@apple.com [mailto:steve...@apple.com] 
Sent: Friday, May 13, 2016 1:27 PM
To: Liu, Yaxun (Sam) 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r269431 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Yaxun

You seems missing some override keyword that triggers 
-Winconsistent-missing-override. See:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/24442/warnings8Result/new/

Here is a patch to fix them:

diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 
b1b12e4..20f1e95 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -2087,7 +2087,7 @@ public:
 return true;
   }
 
-   void setSupportedOpenCLOpts() {
+   void setSupportedOpenCLOpts() override {
  auto &Opts = getSupportedOpenCLOpts();
  Opts.cl_clang_storage_class_specifiers = 1;
  Opts.cl_khr_gl_sharing = 1;
@@ -2731,7 +2731,7 @@ public:
 return true;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 getSupportedOpenCLOpts().setAll();
   }
 };
@@ -7877,7 +7877,7 @@ public:
 return CC_SpirFunction;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 // Assume all OpenCL extensions and optional core features are supported
 // for SPIR since it is a generic target.
 getSupportedOpenCLOpts().setAll();

Thanks

Steven

> On May 13, 2016, at 8:44 AM, Yaxun Liu via cfe-commits 
>  wrote:
> 
> Author: yaxunl
> Date: Fri May 13 10:44:37 2016
> New Revision: 269431
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269431&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.
> 
> 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=269431&r1=269430&r2=269431&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13 
> +++ 10:44:37 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=269431&r1=269430&r2=269431&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 13 10:44:37 
> +++ 2016
> @@ -160,18 +160,6 @@ public:
> fp_contract(LangOpts.DefaultFPContract) {} };
> 
> -/// \brief OpenCL volatile opti

r269440 - Fix module map typo in r269347.

2016-05-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 13 12:28:51 2016
New Revision: 269440

URL: http://llvm.org/viewvc/llvm-project?rev=269440&view=rev
Log:
Fix module map typo in r269347.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=269440&r1=269439&r2=269440&view=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Fri May 13 12:28:51 2016
@@ -12,6 +12,7 @@ module Clang_AST {
   umbrella "AST"
 
   textual header "AST/BuiltinTypes.def"
+  textual header "AST/OperationKinds.def"
   textual header "AST/TypeLocNodes.def"
   textual header "AST/TypeNodes.def"
 
@@ -43,7 +44,6 @@ module Clang_Basic {
   textual header "Basic/OpenCLExtensions.def"
   textual header "Basic/OpenCLImageTypes.def"
   textual header "Basic/OpenMPKinds.def"
-  textual header "Basic/OperationKinds.def"
   textual header "Basic/OperatorKinds.def"
   textual header "Basic/Sanitizers.def"
   textual header "Basic/TokenKinds.def"


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


Re: r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-13 Thread David Majnemer via cfe-commits
This seems to crash clang:
struct S {
  void f() __unaligned;
};
void S::f() __unaligned {
}

clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk
clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation,
clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation,
clang::SourceLocation, unsigned int, bool, clang::SourceLocation,
clang::SourceLocation, clang::SourceLocation, clang::SourceLocation,
clang::SourceLocation, clang::ExceptionSpecificationType,
clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int,
clang::Expr *, CachedTokens *, clang::SourceLocation,
clang::SourceLocation, clang::Declarator &, TypeResult): Assertion
`I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.


On Wed, May 11, 2016 at 11:38 AM, Andrey Bokhanko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: asbokhan
> Date: Wed May 11 13:38:21 2016
> New Revision: 269220
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269220&view=rev
> Log:
> [MSVC] Implementation of __unaligned as a proper type qualifier
>
> This patch implements __unaligned (MS extension) as a proper type qualifier
> (before that, it was implemented as an ignored attribute).
>
> It also fixes PR27367 and PR27666.
>
> Differential Revision: http://reviews.llvm.org/D20103
>
> Modified:
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Basic/AddressSpaces.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/DeclSpec.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseTentative.cpp
> cfe/trunk/lib/Sema/DeclSpec.cpp
> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
> cfe/trunk/test/Sema/MicrosoftExtensions.c
> cfe/trunk/test/Sema/address_spaces.c
> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016
> @@ -111,6 +111,7 @@ namespace clang {
>  /// The collection of all-type qualifiers we support.
>  /// Clang supports five independent qualifiers:
>  /// * C99: const, volatile, and restrict
> +/// * MS: __unaligned
>  /// * Embedded C (TR18037): address spaces
>  /// * Objective C: the GC attributes (none, weak, or strong)
>  class Qualifiers {
> @@ -152,8 +153,8 @@ public:
>
>enum {
>  /// The maximum supported address space number.
> -/// 24 bits should be enough for anyone.
> -MaxAddressSpace = 0xffu,
> +/// 23 bits should be enough for anyone.
> +MaxAddressSpace = 0x7fu,
>
>  /// The width of the "fast" qualifier mask.
>  FastWidth = 3,
> @@ -265,6 +266,13 @@ public:
>  Mask |= mask;
>}
>
> +  bool hasUnaligned() const { return Mask & UMask; }
> +  void setUnaligned(bool flag) {
> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
> +  }
> +  void removeUnaligned() { Mask &= ~UMask; }
> +  void addUnaligned() { Mask |= UMask; }
> +
>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
> GCAttrShift); }
>void setObjCGCAttr(GC type) {
> @@ -433,7 +441,9 @@ public:
> // ObjC lifetime qualifiers must match exactly.
> getObjCLifetime() == other.getObjCLifetime() &&
> // CVR qualifiers may subset.
> -   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
> CVRMask));
> +   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
> CVRMask)) &&
> +   // U qualifier may superset.
> +   (!other.hasUnaligned() || hasUnaligned());
>}
>
>/// \brief Determines if these qualifiers compatibly include another
> set of
> @@ -501,16 +511,19 @@ public:
>
>  private:
>
> -  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
> -  //   |C R V|GCAttr|Lifetime|AddressSpace|
> +  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
> +  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
>uint32_t Mask;
>
> -  static const uint32_t GCAttrMask = 0x18;
> -  static const uint32_t GCAttrShift = 3;
> -  static const uint32_t LifetimeMask = 0xE0;
> -  static const uint32_t LifetimeShift = 5;
> -  static const uint32_t AddressSpaceMa

Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-05-13 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast updated this revision to Diff 57216.
hubert.reinterpretcast added a comment.

Set requires-clause when creating TemplateParameterLists; NFC

Removes the default argument for the requires-clause constraint expression in 
TemplateParameterList::Create.

An appropriate argument is supplied at the various call sites. Serialization 
changes will be left until the feature is otherwise complete so that the 
version number does not need to be bumped multiple times.


http://reviews.llvm.org/D19322

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5359,6 +5359,7 @@
   AddSourceLocation(TemplateParams->getTemplateLoc());
   AddSourceLocation(TemplateParams->getLAngleLoc());
   AddSourceLocation(TemplateParams->getRAngleLoc());
+  // TODO: Concepts
   Record->push_back(TemplateParams->size());
   for (const auto &P : *TemplateParams)
 AddDeclRef(P);
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -7892,9 +7892,10 @@
   while (NumParams--)
 Params.push_back(ReadDeclAs(F, Record, Idx));
 
+  // TODO: Concepts
   TemplateParameterList* TemplateParams =
 TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc,
-  Params, RAngleLoc);
+  Params, RAngleLoc, nullptr);
   return TemplateParams;
 }
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2947,10 +2947,14 @@
   if (Invalid)
 return nullptr;
 
+  // Note: we substitute into associated constraints later
+  Expr *const UninstantiatedRequiresClause = L->getRequiresClause();
+
   TemplateParameterList *InstL
 = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(),
 L->getLAngleLoc(), Params,
-L->getRAngleLoc());
+L->getRAngleLoc(),
+UninstantiatedRequiresClause);
   return InstL;
 }
 
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -4022,8 +4022,8 @@
  nullptr, false, false);
   QualType TemplArg = QualType(TemplParam->getTypeForDecl(), 0);
   NamedDecl *TemplParamPtr = TemplParam;
-  FixedSizeTemplateParameterListStorage<1> TemplateParamsSt(
-  Loc, Loc, TemplParamPtr, Loc);
+  FixedSizeTemplateParameterListStorage<1, false> TemplateParamsSt(
+  Loc, Loc, TemplParamPtr, Loc, nullptr);
 
   QualType FuncParam = SubstituteAutoTransform(*this, TemplArg).Apply(Type);
   assert(!FuncParam.isNull() &&
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -831,11 +831,10 @@
   if (ExportLoc.isValid())
 Diag(ExportLoc, diag::warn_template_export_unsupported);
 
-  // FIXME: store RequiresClause
   return TemplateParameterList::Create(
   Context, TemplateLoc, LAngleLoc,
   llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()),
-  RAngleLoc);
+  RAngleLoc, RequiresClause);
 }
 
 static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS) {
@@ -1953,7 +1952,7 @@
   // Fabricate an empty template parameter list for the invented header.
   return TemplateParameterList::Create(Context, SourceLocation(),
SourceLocation(), None,
-   SourceLocation());
+   SourceLocation(), nullptr);
 }
 
 return nullptr;
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -235,7 +235,7 @@
 /*Template kw loc*/ SourceLocation(), LAngleLoc,
 llvm::makeArrayRef((NamedDecl *const *)LSI->AutoTemplateParams.data(),
LSI->AutoTemplateParams.size()),
-RAngleLoc);
+RAngleLoc, nullptr);
   }
   return LSI->GLTemplateParameterList;
 }
Index: lib/AST/DeclTemplate.cpp
===
--- lib/AST/DeclTemplate.cpp
+++ lib/AST/DeclTe

[clang-tools-extra] r269441 - [include-fixer] Fix broken dependency shared build

2016-05-13 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Fri May 13 12:38:22 2016
New Revision: 269441

URL: http://llvm.org/viewvc/llvm-project?rev=269441&view=rev
Log:
[include-fixer] Fix broken dependency shared build

Summary:
The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o:
 In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): 
undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o:
 In function `clang::include_fixer::(anonymous 
namespace)::runIncludeFixer(llvm::StringRef, std::vector > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526):
 undefined reference to 
`clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, 
clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, 
std::vector, 
std::allocator > > const&)'
```

Reviewers: bkramer, hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=269441&r1=269440&r2=269441&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Fri May 
13 12:38:22 2016
@@ -47,7 +47,7 @@ public:
 
   // The default constructor is required by YAML traits in
   // LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.
-  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {};
+  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {}
 
   SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
  int LineNumber, const std::vector &Contexts);

Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt?rev=269441&r1=269440&r2=269441&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Fri May 13 
12:38:22 2016
@@ -8,4 +8,5 @@ target_link_libraries(clang-include-fixe
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )

Modified: clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt?rev=269441&r1=269440&r2=269441&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt

Re: [PATCH] D20245: [include-fixer] Fix broken dependency shared build

2016-05-13 Thread Etienne Bergeron via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269441: [include-fixer] Fix broken dependency shared build 
(authored by etienneb).

Changed prior to commit:
  http://reviews.llvm.org/D20245?vs=57208&id=57221#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20245

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
  clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt

Index: clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
===
--- clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
+++ clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
@@ -22,6 +22,7 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(find-all-symbols)
Index: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
@@ -8,4 +8,5 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
@@ -47,7 +47,7 @@
 
   // The default constructor is required by YAML traits in
   // LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.
-  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {};
+  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {}
 
   SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
  int LineNumber, const std::vector &Contexts);


Index: clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
===
--- clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
+++ clang-tools-extra/trunk/unittests/include-fixer/CMakeLists.txt
@@ -22,6 +22,7 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(find-all-symbols)
Index: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
@@ -8,4 +8,5 @@
   clangRewrite
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
@@ -47,7 +47,7 @@
 
   // The default constructor is required by YAML traits in
   // LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.
-  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {};
+  SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {}
 
   SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
  int LineNumber, const std::vector &Contexts);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread Adrian McCarthy via cfe-commits
amccarth added inline comments.


Comment at: lib/Driver/MSVCToolChain.cpp:481
@@ +480,3 @@
+
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

majnemer wrote:
> It might be nicer to use a `SmallVector`, 
> or whatever `VersionSize` typically is, here to avoid heap allocation in the 
> common case.
What's the cutoff for "small"?  The version block in cl.exe is about 9KB.


http://reviews.llvm.org/D20136



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


Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/Driver/MSVCToolChain.cpp:481
@@ +480,3 @@
+
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

amccarth wrote:
> majnemer wrote:
> > It might be nicer to use a `SmallVector > sizeof(VS_FIXEDFILEINFO)>`, or whatever `VersionSize` typically is, here to 
> > avoid heap allocation in the common case.
> What's the cutoff for "small"?  The version block in cl.exe is about 9KB.
Using 10K is probably fine, the default stack size on Windows is a massive 1 MB 
and this function is not reentrant.


http://reviews.llvm.org/D20136



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


[PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-13 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: bader, yaxunl.
Anastasia added subscribers: pekka.jaaskelainen, pxli168, cfe-commits.

An implementation of device side enqueue (DSE) - enqueue_kernel and related 
BIFs from OpenCL v2.0 s6.13.17.

This change includes:

1. adding enqueue_kernel, get_kernel_work_group_size and 
get_kernel_preferred_work_group_size_multiple as Clang builtins with a custom 
check. 

Example:
  enqueue_kernel(.../*ommited params*/, block, /*optional sizes of passed block 
args if any*/)

This allows diagnosing parameters of the passed block variable (the spec 
mandates them to be 'local void*' type) and we can check different overloads 
too (Table 6.31).

2. IR generation with an internal library call for each new builtins used in 
the CL code, reusing ObjC block generation.

For the following example of CL code:

  kernel void device_side_enqueue(…) {
… /*declare default_queue, flags, ndrange, a, b here*/
enqueue_kernel(default_queue, flags, ndrange, ^(void) { a + b; });
  }

The generated IR could be:

  ; from ObjC block CodeGen (the second field contains the size of the block 
literal record)
  @__block_descriptor_tmp = internal constant { i64, i64, i8*, i8* } { i64 0, 
i64 52, i8* getelementptr inbounds ([35 x i8]* @.str, i32 0, i32 0), i8* null } 
  ...
  define void @device_side_enqueue() {
...
; from ObjC block CodeGen (block literal record with a capture)
%block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32, 
i32}>
; from ObjC block CodeGen - store block descriptor and block captures below
...
; from ObjC block CodeGen (set pointer to block definition code)
%block.invoke = getelementptr inbounds <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32, i32}>* %block, i64 0, i32 3 * 
store i8* bitcast (void (i8*)* @__device_side_enqueue_block_invoke to i8*), 
i8** %block.invoke *
; potential impl of OpenCL CodeGen (cast from block literal record ptr to 
void ptr)
%1 = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32, 
i32}>* %block to i8*
; potential impl of OpenCL CodeGen (this function will have additional 
integer params at the end if the block has any parameters to be passed to)
 ... call i32 @__enqueue_kernel_impl(..., i8* %1)
...
  }

  define internal void @__device_side_enqueue_block_invoke(i8* nocapture 
readonly %.block_descriptor) { ; from ObjC block CodeGen (this can have more 
params of local void* type)
; from ObjC block CodeGen - load captures below
…
; from ObjC block CodeGen - original body of block
…
  }

Note that there are different versions of __enqueue_kernel_impl with unique 
name each. These functions will have to be implemented as a part of an OpenCL 
runtime library which will get a block literal data structure (allocated 
locally as in this example if capture is present or as a global variable 
otherwise), sizes of each block literal parameter (from 'local void*' list) and 
other omitted arguments at the beginning - mainly opaque objects, and will 
perform necessary steps to enqueue work specified by the block. The block 
literal record itself contains all important bits to facilitate basic 
implementation of DSE: a pointer to a block function definition, captured 
fields, and size of the block literal record. We can also discuss and implement 
some optimisations later on or as a part of this work. The implementation of 
__enqueue_kernel_impl will have to take care of (1) initiating execution of the 
block invoke code pointed to by the block literal record (%block.invoke in the 
example above), (2) copying captured variables in the accessible memory 
location, (3) performing some sort of memory management to allocate space for 
'local void*' parameters passed to the block if any.

Additional changes not included in this change:

1. Modifications of ObjC blocks IR generation. A block literal record currently 
contains a number of fields that are not needed for OpenCL, i.e. isa, flags, 
copy and dispose helpers. They can be removed when compiling in OpenCL mode. We 
might potentially add extra fields to enable more efficient support of DSE or 
facilitate compiler optimisations. Ideas are welcome! I expect some places 
might require taking care of address spaces too.

2. Potentially change of existing OpenCL types is needed. At least it seems 
like we might need to handle the ndrange_t type differently than we do 
currently. It's an opaque type now, but we need it to be allocated on a stack 
because a local variable of that type can be declared in CL code.


http://reviews.llvm.org/D20249

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/clang-builtin-version.cl

Index

Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-13 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/Builtins.h:39
@@ -38,3 +38,3 @@
   MS_LANG = 0x10, // builtin requires MS mode.
-  OCLC_LANG = 0x20,   // builtin for OpenCL C only.
+  OCLC20_LANG = 0x20, // builtin for OpenCL C only.
   ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.

This is necessary in order to remove CL2.0 BIFs from the list of Clang 
identifiers in other CL versions.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7820
@@ +7819,3 @@
+def err_opencl_function_not_supported : Error<
+  "this function is not supported in this version of CL">;
+def err_opencl_enqueue_kernel_incorrect_args : Error<

This diagnostic should follow the latest version reporting style.


http://reviews.llvm.org/D20249



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


Re: [PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

2016-05-13 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

Please make sure the test files have newlines at the end.
"touch-pragma-once.cpp" should probably be named something like 
"pragma-once-timestamp.cpp".


http://reviews.llvm.org/D20243



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


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

2016-05-13 Thread Liu, Yaxun (Sam) via cfe-commits
BTW is there a way to turn on this warning with CMake? I could not see this 
warning in my own build.

Thanks.

Sam

-Original Message-
From: Liu, Yaxun (Sam) 
Sent: Friday, May 13, 2016 1:33 PM
To: 'steve...@apple.com' 
Cc: cfe-commits@lists.llvm.org
Subject: RE: r269431 - [OpenCL] Add supported OpenCL extensions to target info.

Thanks Steven.

I have reverted my change. I will apply your patch and re-commit.

Sam

-Original Message-
From: steve...@apple.com [mailto:steve...@apple.com]
Sent: Friday, May 13, 2016 1:27 PM
To: Liu, Yaxun (Sam) 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r269431 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Yaxun

You seems missing some override keyword that triggers 
-Winconsistent-missing-override. See:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/24442/warnings8Result/new/

Here is a patch to fix them:

diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 
b1b12e4..20f1e95 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -2087,7 +2087,7 @@ public:
 return true;
   }
 
-   void setSupportedOpenCLOpts() {
+   void setSupportedOpenCLOpts() override {
  auto &Opts = getSupportedOpenCLOpts();
  Opts.cl_clang_storage_class_specifiers = 1;
  Opts.cl_khr_gl_sharing = 1;
@@ -2731,7 +2731,7 @@ public:
 return true;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 getSupportedOpenCLOpts().setAll();
   }
 };
@@ -7877,7 +7877,7 @@ public:
 return CC_SpirFunction;
   }
 
-  void setSupportedOpenCLOpts() {
+  void setSupportedOpenCLOpts() override {
 // Assume all OpenCL extensions and optional core features are supported
 // for SPIR since it is a generic target.
 getSupportedOpenCLOpts().setAll();

Thanks

Steven

> On May 13, 2016, at 8:44 AM, Yaxun Liu via cfe-commits 
>  wrote:
> 
> Author: yaxunl
> Date: Fri May 13 10:44:37 2016
> New Revision: 269431
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269431&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.
> 
> 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=269431&r1=269430&r2=269431&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13
> +++ 10:44:37 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=269431&r1=269430&r2=269431&view=diff
> ==

Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-13 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Headers/opencl-c.h:7452
@@ +7451,3 @@
+
+// OpenCL v1.2 s6.12.2, v2.0 s6.13.2 - Math functions
+

Could you put OpenCL v1.1 section too?


Comment at: lib/Headers/opencl-c.h:7767
@@ +7766,3 @@
+/**
+ * Round to integral value using the round to +ve
+ * infinity rounding mode.

What does +ve mean?


Comment at: lib/Headers/opencl-c.h:7795
@@ +7794,3 @@
+ * Returns x with its sign changed to match the sign of
+ * y.
+ */

Could y be merged with the previous line?


Comment at: lib/Headers/opencl-c.h:7952
@@ +7951,3 @@
+/**
+ * Compute the base- e exponential of x.
+ */

Can't read this comment.

Perhaps: "Compute base e exponent"?


Comment at: lib/Headers/opencl-c.h:8306
@@ +8305,3 @@
+#else
+float __attribute__((overloadable)) fract(float x, __global float *iptr);
+float2 __attribute__((overloadable)) fract(float2 x, __global float2 *iptr);

Does this mean that all non-generic versions are not available in CL2.0 forcing 
the dynamic AS conversion for all BIFs with a pointer type?

Wondering if adding those unconditionally would be better thing to do...


Comment at: lib/Headers/opencl-c.h:8457
@@ +8456,3 @@
+/**
+ * Compute the value of the square root of x^2+ y^2
+ * without undue overflow or underflow.

Could you add space please: x^2 + y^2


Comment at: lib/Headers/opencl-c.h:9110
@@ +9109,3 @@
+ */
+float __const_func remainder(float x, float y);
+float2 __const_func remainder(float2 x, float2 y);

Overloadable here and in other places too?


Comment at: lib/Headers/opencl-c.h:12772
@@ +12771,3 @@
+#ifdef cl_khr_fp16
+half __attribute__((overloadable)) vload(size_t offset, const half *p);
+half2 __attribute__((overloadable)) vload2(size_t offset, const half *p);

Should it be vload_half instead?


Comment at: lib/Headers/opencl-c.h:14484
@@ +14483,3 @@
+long __attribute__((overloadable)) atom_sub(volatile __global long *p, long 
val);
+unsigned long __attribute__((overloadable)) atom_sub(volatile __global 
unsigned long *p, unsigned long val);
+long __attribute__((overloadable)) atom_sub(volatile __local long *p, long 
val);

btw, perhaps it's a good idea to have a macro for 
__attribute__((overloadable)). This should be relatively simple to replace 
everywhere.


Comment at: lib/Headers/opencl-c.h:14766
@@ +14765,3 @@
+
+ATOMIC_INIT_PROTOTYPE(int)
+ATOMIC_INIT_PROTOTYPE(uint)

Let's not have macros for function declarations. As commented earlier they can 
break proper diagnostics reporting (ie. diagnostics will display macro instead 
of actual function).


Comment at: lib/Headers/opencl-c.h:15674
@@ +15673,3 @@
+/**
+ * Use the coordinate (coord.z) to index into the
+ * 2D image array object and (coord.x, coord.y) to do an

I feel that some bits of this description are being repeated multiple times. 
Could we have a common description at the beginning instead that would cover 
all the different cases.


Comment at: lib/Headers/opencl-c.h:16220
@@ +16219,3 @@
+/**
+ * Write color value to location specified by coordinate
+ * (coord.x) in the 1D image object specified by index

The same here. Could we unify the description for all write_image functions 
somehow?


Comment at: lib/Headers/opencl-c.h:16960
@@ +16959,3 @@
+
+#define WG_BROADCAST_1D_DECL(type) \
+type __attribute__((overloadable)) work_group_broadcast(type a, size_t 
local_id);

Let's remove macros from here too.


Comment at: lib/Headers/opencl-c.h:17051
@@ +17050,3 @@
+#define CLK_SUCCESS 0
+#define CLK_ENQUEUE_FAILURE -101
+#define CLK_INVALID_QUEUE   -102

Are those arbitrary taken values I am guessing?


Comment at: lib/Headers/opencl-c.h:17099
@@ +17098,3 @@
+
+// ToDo: Add enqueue_kernel as a Clang builtin because it requires custom 
check of type of variadic 
+// arguments as well as block arguments.

Could we remove the enqueue_kernel as it's being added as Clang builtin? It's 
prototype is incorrect here anyways.

Btw, I have started the review for it: http://reviews.llvm.org/D20249


Comment at: lib/Headers/opencl-c.h:17252
@@ +17251,3 @@
+/**
+ * Use the coordinate (x) to do an element lookup in
+ * the mip-level specified by the Level-of-Detail (lod)

I think this should be better grouped with other image functions above.


http://reviews.llvm.org/D18369



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

Re: [PATCH] D20137: [PCH] Fixed bugs with preamble invalidation when files change (on Windows)

2016-05-13 Thread Cameron via cfe-commits
cameron314 updated this revision to Diff 57222.
cameron314 added a comment.

Updated patch to include later fixes I had made after the initial change.


http://reviews.llvm.org/D20137

Files:
  include/clang/Basic/FileManager.h
  include/clang/Frontend/ASTUnit.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp

Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1378,7 +1378,7 @@
   
   // First, make a record of those files that have been overridden via
   // remapping or unsaved_files.
-  llvm::StringMap OverriddenFiles;
+  std::map OverriddenFiles;
   for (const auto &R : PreprocessorOpts.RemappedFiles) {
 if (AnyFileChanged)
   break;
@@ -1391,40 +1391,47 @@
   break;
 }
 
-OverriddenFiles[R.first] = PreambleFileHash::createForFile(
+OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
 Status.getSize(), Status.getLastModificationTime().toEpochTime());
   }
 
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
 if (AnyFileChanged)
   break;
-OverriddenFiles[RB.first] =
+
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
+  AnyFileChanged = true;
+  break;
+}
+
+OverriddenFiles[Status.getUniqueID()] =
 PreambleFileHash::createForMemoryBuffer(RB.second);
   }

   // Check whether anything has changed.
-  for (llvm::StringMap::iterator 
+  for (FilesInPreambleMap::iterator
  F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
!AnyFileChanged && F != FEnd; 
++F) {
-llvm::StringMap::iterator Overridden
-  = OverriddenFiles.find(F->first());
+std::map::iterator Overridden
+  = OverriddenFiles.find(F->first);
 if (Overridden != OverriddenFiles.end()) {
   // This file was remapped; check whether the newly-mapped file 
   // matches up with the previous mapping.
-  if (Overridden->second != F->second)
+  if (Overridden->second != F->second.second)
 AnyFileChanged = true;
   continue;
 }
 
 // The file was not remapped; check whether it has changed on disk.
 vfs::Status Status;
-if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
+if (FileMgr->getNoncachedStatValue(F->second.first, Status)) {
   // If we can't stat the file, assume that something horrible happened.
   AnyFileChanged = true;
-} else if (Status.getSize() != uint64_t(F->second.Size) ||
+} else if (Status.getSize() != uint64_t(F->second.second.Size) ||
Status.getLastModificationTime().toEpochTime() !=
-   uint64_t(F->second.ModTime))
+   uint64_t(F->second.second.ModTime))
   AnyFileChanged = true;
   }
   
@@ -1612,12 +1619,14 @@
 if (!File || File == SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()))
   continue;
 if (time_t ModTime = File->getModificationTime()) {
-  FilesInPreamble[File->getName()] = PreambleFileHash::createForFile(
-  File->getSize(), ModTime);
+  FilesInPreamble[File->getUniqueID()] = std::make_pair(
+File->getName(),
+PreambleFileHash::createForFile(File->getSize(), ModTime));
 } else {
   llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File);
-  FilesInPreamble[File->getName()] =
-  PreambleFileHash::createForMemoryBuffer(Buffer);
+  FilesInPreamble[File->getUniqueID()] = std::make_pair(
+File->getName(),
+PreambleFileHash::createForMemoryBuffer(Buffer));
 }
   }
 
Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -301,6 +301,11 @@
 return &UFE;
   }
 
+  if (UFE.isVirtual()) {
+UFE.Name = InterndFileName;
+return &UFE;
+  }
+
   // Otherwise, we don't have this file yet, add it.
   UFE.Name= InterndFileName;
   UFE.Size = Data.Size;
@@ -312,6 +317,7 @@
   UFE.InPCH = Data.InPCH;
   UFE.File = std::move(F);
   UFE.IsValid = true;
+  UFE.IsVirtual = true;
   return &UFE;
 }
 
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -31,6 +31,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/FileSystem.h"
 #include 
 #include 
 #include 
@@ -264,12 +265,15 @@
   /// a line after skipping the preamble.
   bool PreambleEndsAtStartOfLine;
 
+  typedef std::map> FilesInPreambleMap;
+
   /// \brief Keeps track of the files that we

Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-13 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Headers/opencl-c.h:14057
@@ +14056,3 @@
+event_t __attribute__((overloadable)) async_work_group_copy(__local float2 
*dst, const __global float2 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local char3 
*dst, const __global char3 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local uchar3 
*dst, const __global uchar3 *src, size_t num_elements, event_t event);

yaxunl wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > If this representation is not generic enough. Any suggestion for an 
> > > alternative? Thanks.
> > I don't think Spec imposes any specific implementation of this macro.
> > 
> > I am thinking we might better leave it out to allow adding in a way 
> > suitable for other implementations.
> How about this?
> 
>   #ifndef ATOMIC_VAR_INIT
>   #define ATOMIC_VAR_INIT(x) (x)
>   #endif
> 
> This way we have a default declaration and also allows user to override it.
> 
> Another way is to remove it from header and define it in Clang on target by 
> target basis.
> 
Not sure. I guess this way would work too.


http://reviews.llvm.org/D18369



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


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

2016-05-13 Thread Steven Wu via cfe-commits
It is part of -Wall group and it should be on by default when you building 
clang. That warning is added into clang some time in 2014. Make sure you are 
not using a compiler that is too old.

Steven

> On May 13, 2016, at 10:58 AM, Liu, Yaxun (Sam)  wrote:
> 
> BTW is there a way to turn on this warning with CMake? I could not see this 
> warning in my own build.
> 
> Thanks.
> 
> Sam
> 
> -Original Message-
> From: Liu, Yaxun (Sam) 
> Sent: Friday, May 13, 2016 1:33 PM
> To: 'steve...@apple.com' 
> Cc: cfe-commits@lists.llvm.org
> Subject: RE: r269431 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Thanks Steven.
> 
> I have reverted my change. I will apply your patch and re-commit.
> 
> Sam
> 
> -Original Message-
> From: steve...@apple.com [mailto:steve...@apple.com]
> Sent: Friday, May 13, 2016 1:27 PM
> To: Liu, Yaxun (Sam) 
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r269431 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Hi Yaxun
> 
> You seems missing some override keyword that triggers 
> -Winconsistent-missing-override. See:
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/24442/warnings8Result/new/
> 
> Here is a patch to fix them:
> 
> diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 
> b1b12e4..20f1e95 100644
> --- a/lib/Basic/Targets.cpp
> +++ b/lib/Basic/Targets.cpp
> @@ -2087,7 +2087,7 @@ public:
> return true;
>   }
> 
> -   void setSupportedOpenCLOpts() {
> +   void setSupportedOpenCLOpts() override {
>  auto &Opts = getSupportedOpenCLOpts();
>  Opts.cl_clang_storage_class_specifiers = 1;
>  Opts.cl_khr_gl_sharing = 1;
> @@ -2731,7 +2731,7 @@ public:
> return true;
>   }
> 
> -  void setSupportedOpenCLOpts() {
> +  void setSupportedOpenCLOpts() override {
> getSupportedOpenCLOpts().setAll();
>   }
> };
> @@ -7877,7 +7877,7 @@ public:
> return CC_SpirFunction;
>   }
> 
> -  void setSupportedOpenCLOpts() {
> +  void setSupportedOpenCLOpts() override {
> // Assume all OpenCL extensions and optional core features are supported
> // for SPIR since it is a generic target.
> getSupportedOpenCLOpts().setAll();
> 
> Thanks
> 
> Steven
> 
>> On May 13, 2016, at 8:44 AM, Yaxun Liu via cfe-commits 
>>  wrote:
>> 
>> Author: yaxunl
>> Date: Fri May 13 10:44:37 2016
>> New Revision: 269431
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=269431&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.
>> 
>> 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=269431&r1=269430&r2=269431&view=diff
>> ==
>> 
>> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May 13
>> +++ 10:44:37 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 

Re: [PATCH] D20137: [PCH] Fixed bugs with preamble invalidation when files change (on Windows)

2016-05-13 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/FileManager.cpp:304-307
@@ -303,1 +303,6 @@
 
+  if (UFE.isVirtual()) {
+UFE.Name = InterndFileName;
+return &UFE;
+  }
+

It looks like this is unreachable: `IsVirtual` is only ever `true` when 
`IsValid` is also `true`, and we don't reach this line if `UFE.isValid()`. As 
this is the only consumer of `FileEntry::IsValid`, it looks like it does 
nothing. Am I missing something?


Comment at: lib/Frontend/ASTUnit.cpp:1402-1406
@@ +1401,7 @@
+
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
+  AnyFileChanged = true;
+  break;
+}
+

If there are multiple file names with the same inode, `RB.first` is an 
arbitrarily-chosen one of those names, and stat'ing it isn't sufficient to 
check that none of the other names for the file have changed. Maybe we need to 
store a list of filenames used for each `UniqueID`?


http://reviews.llvm.org/D20137



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


Re: [PATCH] D20136: Get default -fms-compatibility-version from cl.exe's version

2016-05-13 Thread Adrian McCarthy via cfe-commits
amccarth marked an inline comment as done.


Comment at: lib/Driver/MSVCToolChain.cpp:481
@@ +480,3 @@
+
+  std::vector VersionBlock(VersionSize);
+  if (!::GetFileVersionInfoW(ClExeWide.c_str(), 0, VersionSize,

majnemer wrote:
> amccarth wrote:
> > majnemer wrote:
> > > It might be nicer to use a `SmallVector > > sizeof(VS_FIXEDFILEINFO)>`, or whatever `VersionSize` typically is, here 
> > > to avoid heap allocation in the common case.
> > What's the cutoff for "small"?  The version block in cl.exe is about 9KB.
> Using 10K is probably fine, the default stack size on Windows is a massive 1 
> MB and this function is not reentrant.
My mistake.  It's a smidge over 1KB, (still more than sizeof(VS_FIXEDFILEINFO)) 
so I've make a SmallVector of 2KB.


http://reviews.llvm.org/D20136



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


r269457 - Use marginally more appropriate functions to detect if we should declare an

2016-05-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 13 13:48:05 2016
New Revision: 269457

URL: http://llvm.org/viewvc/llvm-project?rev=269457&view=rev
Log:
Use marginally more appropriate functions to detect if we should declare an
implicit copy constructor/assignment, and other minor cleanups. No
functionality change intended.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=269457&r1=269456&r2=269457&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri May 13 13:48:05 2016
@@ -6463,7 +6463,7 @@ void Sema::AddImplicitlyDeclaredMembersT
   ClassDecl->hasInheritedConstructor())
 DeclareImplicitDefaultConstructor(ClassDecl);
 
-  if (!ClassDecl->hasUserDeclaredCopyConstructor()) {
+  if (ClassDecl->needsImplicitCopyConstructor()) {
 ++ASTContext::NumImplicitCopyConstructors;
 
 // If the properties or semantics of the copy constructor couldn't be
@@ -6482,7 +6482,7 @@ void Sema::AddImplicitlyDeclaredMembersT
   DeclareImplicitMoveConstructor(ClassDecl);
   }
 
-  if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
+  if (ClassDecl->needsImplicitCopyAssignment()) {
 ++ASTContext::NumImplicitCopyAssignmentOperators;
 
 // If we have a dynamic class, then the copy assignment operator may be
@@ -6505,7 +6505,7 @@ void Sema::AddImplicitlyDeclaredMembersT
   DeclareImplicitMoveAssignment(ClassDecl);
   }
 
-  if (!ClassDecl->hasUserDeclaredDestructor()) {
+  if (ClassDecl->needsImplicitDestructor()) {
 ++ASTContext::NumImplicitDestructors;
 
 // If we have a dynamic class, then the destructor may be virtual, so we
@@ -8946,6 +8946,7 @@ void Sema::CheckImplicitSpecialMemberDec
 if (auto *Acceptable = R.getAcceptableDecl(D))
   R.addDecl(Acceptable);
   R.resolveKind();
+  R.suppressDiagnostics();
 
   CheckFunctionDeclaration(S, FD, R, /*IsExplicitSpecialization*/false);
 }

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=269457&r1=269456&r2=269457&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri May 13 13:48:05 2016
@@ -738,11 +738,11 @@ void Sema::ForceDeclarationOfImplicitMem
   if (getLangOpts().CPlusPlus11) {
 // If the move constructor has not yet been declared, do so now.
 if (Class->needsImplicitMoveConstructor())
-  DeclareImplicitMoveConstructor(Class); // might not actually do it
+  DeclareImplicitMoveConstructor(Class);
 
 // If the move assignment operator has not yet been declared, do so now.
 if (Class->needsImplicitMoveAssignment())
-  DeclareImplicitMoveAssignment(Class); // might not actually do it
+  DeclareImplicitMoveAssignment(Class);
   }
 
   // If the destructor has not yet been declared, do so now.


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


[PATCH] D20253: clang-rename: fix missing clangLex dependency

2016-05-13 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

Blind fix for 
.

http://reviews.llvm.org/D20253

Files:
  clang-rename/CMakeLists.txt

Index: clang-rename/CMakeLists.txt
===
--- clang-rename/CMakeLists.txt
+++ clang-rename/CMakeLists.txt
@@ -10,6 +10,7 @@
   clangAST
   clangBasic
   clangIndex
+  clangLex
   clangToolingCore
   )
 


Index: clang-rename/CMakeLists.txt
===
--- clang-rename/CMakeLists.txt
+++ clang-rename/CMakeLists.txt
@@ -10,6 +10,7 @@
   clangAST
   clangBasic
   clangIndex
+  clangLex
   clangToolingCore
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20253: clang-rename: fix missing clangLex dependency

2016-05-13 Thread Miklos Vajna via cfe-commits
vmiklos abandoned this revision.
vmiklos added a comment.

Ah, already fixed by http://reviews.llvm.org/D20240, sorry for the noise. :-)


http://reviews.llvm.org/D20253



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


Re: [PATCH] D20240: [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

Thanks for fixing the problem I introduced. :-)


http://reviews.llvm.org/D20240



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


Re: [PATCH] D20240: [clang-rename] Fix broken dependency on shared build.

2016-05-13 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D20240#429910, @vmiklos wrote:

> Thanks for fixing the problem I introduced. :-)


No worries, I did the same twice this week.


http://reviews.llvm.org/D20240



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


  1   2   >