[PATCH] D15802: [clang-tidy] Don't generate duplicated blank line in add_new_check.py script.

2015-12-29 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D15802

Files:
  clang-tidy/add_new_check.py
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  docs/clang-tidy/checks/list.rst

Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::   
+   CERT-ttest
cert-setlongjmp
cert-static-object-exception
cert-thrown-exception-type
Index: clang-tidy/cert/CMakeLists.txt
===
--- clang-tidy/cert/CMakeLists.txt
+++ clang-tidy/cert/CMakeLists.txt
@@ -5,6 +5,7 @@
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
   ThrownExceptionTypeCheck.cpp
+  TtestCheck.cpp
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
Index: clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tidy/cert/CERTTidyModule.cpp
@@ -19,6 +19,7 @@
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
 #include "ThrownExceptionTypeCheck.h"
+#include "TtestCheck.h"
 #include "VariadicFunctionDefCheck.h"
 
 namespace clang {
@@ -30,6 +31,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 // C++ checkers
 // DCL
+CheckFactories.registerCheck(
+"CERT-ttest");
 CheckFactories.registerCheck(
 "cert-dcl50-cpp");
 CheckFactories.registerCheck(
Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -92,7 +92,6 @@
 } // namespace clang
 
 #endif // %(header_guard)s
-
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
@@ -146,7 +145,6 @@
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-
 """ % {'check_name': check_name_camel,
'module': module})
 


Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::   
+   CERT-ttest
cert-setlongjmp
cert-static-object-exception
cert-thrown-exception-type
Index: clang-tidy/cert/CMakeLists.txt
===
--- clang-tidy/cert/CMakeLists.txt
+++ clang-tidy/cert/CMakeLists.txt
@@ -5,6 +5,7 @@
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
   ThrownExceptionTypeCheck.cpp
+  TtestCheck.cpp
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
Index: clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tidy/cert/CERTTidyModule.cpp
@@ -19,6 +19,7 @@
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
 #include "ThrownExceptionTypeCheck.h"
+#include "TtestCheck.h"
 #include "VariadicFunctionDefCheck.h"
 
 namespace clang {
@@ -30,6 +31,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 // C++ checkers
 // DCL
+CheckFactories.registerCheck(
+"CERT-ttest");
 CheckFactories.registerCheck(
 "cert-dcl50-cpp");
 CheckFactories.registerCheck(
Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -92,7 +92,6 @@
 } // namespace clang
 
 #endif // %(header_guard)s
-
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
@@ -146,7 +145,6 @@
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-
 """ % {'check_name': check_name_camel,
'module': module})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r256545 - [ms inline asm] Add support for label names with '$' chars

2015-12-29 Thread Marina Yatsina via cfe-commits
Author: myatsina
Date: Tue Dec 29 02:49:34 2015
New Revision: 256545

URL: http://llvm.org/viewvc/llvm-project?rev=256545&view=rev
Log:
[ms inline asm] Add support for label names with '$' chars

In MS inline asm syntax a label with '$' char produces an error, while in AT&T 
it does not.
In AT&T inline asm syntax Clang escapes the '$' char and replaces it with "$$". 
Adopted same approach for MS syntax.

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


Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=256545&r1=256544&r2=256545&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Dec 29 02:49:34 2015
@@ -750,7 +750,15 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
 // Create an internal name for the label.  The name should not be a valid 
mangled
 // name, and should be unique.  We use a dot to make the name an invalid 
mangled
 // name.
-OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << 
ExternalLabelName;
+OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__";
+for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end();
+ ++it) {
+  OS << *it;
+  if (*it == '$') {
+// We escape '$' in asm strings by replacing it with "$$"
+OS << '$';
+  }
+}
 Label->setMSAsmLabel(OS.str());
   }
   if (AlwaysCreate) {

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=256545&r1=256544&r2=256545&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Dec 29 02:49:34 2015
@@ -616,6 +616,15 @@ void label4() {
   // CHECK: call void asm sideeffect inteldialect 
"{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label5() {
+  __asm {
+jmp dollar_label$
+dollar_label$:
+  }
+  // CHECK-LABEL: define void @label5
+  // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:",
 "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;


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


Re: [PATCH] D15795: [ms inline asm] Add support for label names with '$' chars

2015-12-29 Thread Marina Yatsina via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256545: [ms inline asm] Add support for label names with '$' 
chars (authored by myatsina).

Changed prior to commit:
  http://reviews.llvm.org/D15795?vs=43692&id=43718#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15795

Files:
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm.c

Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -750,7 +750,15 @@
 // Create an internal name for the label.  The name should not be a valid 
mangled
 // name, and should be unique.  We use a dot to make the name an invalid 
mangled
 // name.
-OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << 
ExternalLabelName;
+OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__";
+for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end();
+ ++it) {
+  OS << *it;
+  if (*it == '$') {
+// We escape '$' in asm strings by replacing it with "$$"
+OS << '$';
+  }
+}
 Label->setMSAsmLabel(OS.str());
   }
   if (AlwaysCreate) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -616,6 +616,15 @@
   // CHECK: call void asm sideeffect inteldialect 
"{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label5() {
+  __asm {
+jmp dollar_label$
+dollar_label$:
+  }
+  // CHECK-LABEL: define void @label5
+  // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:",
 "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;


Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -750,7 +750,15 @@
 // Create an internal name for the label.  The name should not be a valid mangled
 // name, and should be unique.  We use a dot to make the name an invalid mangled
 // name.
-OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName;
+OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__";
+for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end();
+ ++it) {
+  OS << *it;
+  if (*it == '$') {
+// We escape '$' in asm strings by replacing it with "$$"
+OS << '$';
+  }
+}
 Label->setMSAsmLabel(OS.str());
   }
   if (AlwaysCreate) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -616,6 +616,15 @@
   // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label5() {
+  __asm {
+jmp dollar_label$
+dollar_label$:
+  }
+  // CHECK-LABEL: define void @label5
+  // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r256546 - clang-format: [JS/TypeScript] Support "enum" as property name.

2015-12-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Dec 29 02:54:23 2015
New Revision: 256546

URL: http://llvm.org/viewvc/llvm-project?rev=256546&view=rev
Log:
clang-format: [JS/TypeScript] Support "enum" as property name.

Before:
  enum: string
  [];

After:
  enum: string[];

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=256546&r1=256545&r2=256546&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Dec 29 02:54:23 2015
@@ -818,7 +818,8 @@ void UnwrappedLineParser::parseStructura
 case tok::kw_enum:
   // parseEnum falls through and does not yet add an unwrapped line as an
   // enum definition can start a structural element.
-  parseEnum();
+  if (!parseEnum())
+break;
   // This only applies for C++.
   if (Style.Language != FormatStyle::LK_Cpp) {
 addUnwrappedLine();
@@ -1524,11 +1525,17 @@ void UnwrappedLineParser::parseAccessSpe
   addUnwrappedLine();
 }
 
-void UnwrappedLineParser::parseEnum() {
+bool UnwrappedLineParser::parseEnum() {
   // Won't be 'enum' for NS_ENUMs.
   if (FormatTok->Tok.is(tok::kw_enum))
 nextToken();
 
+  // In TypeScript, "enum" can also be used as property name, e.g. in interface
+  // declarations. An "enum" keyword followed by a colon would be a syntax
+  // error and thus assume it is just an identifier.
+  if (Style.Language == FormatStyle::LK_JavaScript && 
FormatTok->is(tok::colon))
+return false;
+
   // Eat up enum class ...
   if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct))
 nextToken();
@@ -1546,22 +1553,23 @@ void UnwrappedLineParser::parseEnum() {
   // return type. In Java, this can be "implements", etc.
   if (Style.Language == FormatStyle::LK_Cpp &&
   FormatTok->is(tok::identifier))
-return;
+return false;
 }
   }
 
   // Just a declaration or something is wrong.
   if (FormatTok->isNot(tok::l_brace))
-return;
+return true;
   FormatTok->BlockKind = BK_Block;
 
   if (Style.Language == FormatStyle::LK_Java) {
 // Java enums are different.
 parseJavaEnumBody();
-return;
-  } else if (Style.Language == FormatStyle::LK_Proto) {
+return true;
+  }
+  if (Style.Language == FormatStyle::LK_Proto) {
 parseBlock(/*MustBeDeclaration=*/true);
-return;
+return true;
   }
 
   // Parse enum body.
@@ -1571,6 +1579,7 @@ void UnwrappedLineParser::parseEnum() {
   nextToken();
 addUnwrappedLine();
   }
+  return true;
 
   // There is no addUnwrappedLine() here so that we fall through to parsing a
   // structural element afterwards. Thus, in "enum A {} n, m;",

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=256546&r1=256545&r2=256546&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h Tue Dec 29 02:54:23 2015
@@ -96,7 +96,7 @@ private:
   void parseNamespace();
   void parseNew();
   void parseAccessSpecifier();
-  void parseEnum();
+  bool parseEnum();
   void parseJavaEnumBody();
   void parseRecord();
   void parseObjCProtocolList();

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256546&r1=256545&r2=256546&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Dec 29 02:54:23 2015
@@ -762,6 +762,7 @@ TEST_F(FormatTestJS, ClassDeclarations)
 TEST_F(FormatTestJS, InterfaceDeclarations) {
   verifyFormat("interface I {\n"
"  x: string;\n"
+   "  enum: string[];\n"
"}\n"
"var y;");
   // Ensure that state is reset after parsing the interface.


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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:2700
@@ -2685,3 +2699,3 @@
 return;
 
   Aliases.push_back(GD);

rjmccall wrote:
> Please diagnose that the resolver function has the appropriate type here.  
> Given the constraints, you should be able to do this by inspecting the LLVM 
> function.
I did it in checkAliases because here resolver function may not be available 
yet.


Comment at: lib/Sema/SemaDecl.cpp:2316
@@ -2315,3 +2315,3 @@
 ? diag::err_alias_after_tentative
 : diag::err_redefinition;
 S.Diag(VD->getLocation(), Diag) << VD->getDeclName();

rjmccall wrote:
> Please adjust this diagnostic to say something correct for ifuncs.
It is for VarDecl only so it is not applicable to ifunc.


http://reviews.llvm.org/D15524



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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 43721.
DmitryPolukhin marked 17 inline comments as done.
DmitryPolukhin added a comment.

Comments resolved + this patch uses new GlobalIFunc representation in llvm.


http://reviews.llvm.org/D15524

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/ifunc.c
  test/Sema/attr-alias-elf.c
  test/Sema/attr-ifunc.c

Index: test/Sema/attr-ifunc.c
===
--- /dev/null
+++ test/Sema/attr-ifunc.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm -DCHECK_ALIASES %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm %s
+
+#if defined(_WIN32)
+void foo() {}
+void bar() __attribute__((ifunc("foo")));
+//expected-warning@-1 {{'ifunc' attribute ignored}}
+
+#else
+#if defined(CHECK_ALIASES)
+void* f1_ifunc();
+void f1() __attribute__((ifunc("f1_ifunc")));
+//expected-error@-1 {{ifunc must point to a defined function}}
+
+void* f2_a() __attribute__((ifunc("f2_b")));
+//expected-error@-1 {{ifunc definition is part of a cycle}}
+void* f2_b() __attribute__((ifunc("f2_a")));
+//expected-error@-1 {{ifunc definition is part of a cycle}}
+
+void* f3_a() __attribute__((ifunc("f3_b")));
+//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
+void* f3_b() __attribute__((weak, alias("f3_c")));
+void* f3_c() { return 0; }
+
+void f4_ifunc() {}
+void f4() __attribute__((ifunc("f4_ifunc")));
+//expected-error@-1 {{ifunc resolver function must return a pointer}}
+
+void* f5_ifunc(int i) { return 0; }
+void f5() __attribute__((ifunc("f5_ifunc")));
+//expected-error@-1 {{ifunc resolver function must have no parameters}}
+
+#else
+void f1a() __asm("f1");
+void f1a() {}
+//expected-note@-1 {{previous definition is here}}
+void f1() __attribute__((ifunc("f1_ifunc")));
+//expected-error@-1 {{definition with same mangled name as another definition}}
+void* f1_ifunc() { return 0; }
+
+#endif
+#endif
Index: test/Sema/attr-alias-elf.c
===
--- test/Sema/attr-alias-elf.c
+++ test/Sema/attr-alias-elf.c
@@ -55,7 +55,7 @@
 
 void test2_bar() {}
 void test2_foo() __attribute__((weak, alias("test2_bar")));
-void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of alias test2_foo is overridden}}
+void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of test2_foo is overridden}}
 
 void test3_bar() { }
 void test3_foo() __attribute__((section("test"))); // expected-warning {{alias will not be in section 'test' but in the same section as the aliasee}}
Index: test/CodeGen/ifunc.c
===
--- /dev/null
+++ test/CodeGen/ifunc.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s
+
+int foo(int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static int f2(int i) {
+  return i + 2;
+}
+
+typedef int (*foo_t)(int);
+
+int global;
+
+static foo_t foo_ifunc() {
+  return global ? f1 : f2;
+}
+
+int bar() {
+  return foo(1);
+}
+
+extern void goo(void);
+
+void bar2(void) {
+  goo();
+}
+
+extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));
+
+void* goo_ifunc(void) {
+  return 0;
+}
+// CHECK: @foo = ifunc i32 (i32), bitcast (i32 (i32)* ()* @foo_ifunc to i32 (i32)*)
+// CHECK: @goo = ifunc void (), bitcast (i8* ()* @goo_ifunc to void ()*)
+
+// CHECK: call i32 @foo(i32
+// CHECK: call void @goo()
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1529,6 +1529,29 @@
  Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+return;
+
+  // Aliases should be on declarations, not definitions.
+  if (const auto *FD = dyn_cast(D)) {
+if (FD->isThisDeclarationADefinition()) {
+  S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 1;
+  return;
+}
+if (S.Context.getTargetInfo().getTriple().getObjectFormat() !=
+llvm::Triple::ELF) {
+  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+  return;
+}
+  } e

Re: [PATCH] D15410: AnalysisConsumer: use canonical decl for both lookup and store of visited decls

2015-12-29 Thread Aleksei Sidorin via cfe-commits
a.sidorin removed rL LLVM as the repository for this revision.
a.sidorin updated this revision to Diff 43723.
a.sidorin added a comment.

Added a comment.


http://reviews.llvm.org/D15410

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/inlining/analysis-order.c

Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions 
-analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -494,7 +494,9 @@
 // Add the visited callees to the global visited set.
 for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(*I) ? *I : (*I)->getCanonicalDecl());
 }
 VisitedAsTopLevel.insert(D);
   }


Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -494,7 +494,9 @@
 // Add the visited callees to the global visited set.
 for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(*I) ? *I : (*I)->getCanonicalDecl());
 }
 VisitedAsTopLevel.insert(D);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15410: AnalysisConsumer: use canonical decl for both lookup and store of visited decls

2015-12-29 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 43726.
a.sidorin added a comment.

C++11-fy adding loop. (Sorry for the noise.)


http://reviews.llvm.org/D15410

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/inlining/analysis-order.c

Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions 
-analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -492,10 +492,11 @@
(Mgr->options.InliningMode == All ? nullptr : &VisitedCallees));
 
 // Add the visited callees to the global visited set.
-for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
-   E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
-}
+for (const Decl *Callee : VisitedCallees)
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(Callee) ? Callee
+ : Callee->getCanonicalDecl());
 VisitedAsTopLevel.insert(D);
   }
 }


Index: test/Analysis/inlining/analysis-order.c
===
--- /dev/null
+++ test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -492,10 +492,11 @@
(Mgr->options.InliningMode == All ? nullptr : &VisitedCallees));
 
 // Add the visited callees to the global visited set.
-for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
-   E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
-}
+for (const Decl *Callee : VisitedCallees)
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(Callee) ? Callee
+ : Callee->getCanonicalDecl());
 VisitedAsTopLevel.insert(D);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-29 Thread Alexey Bataev via cfe-commits
ABataev marked 2 inline comments as done.


Comment at: test/Sema/attr-x86-interrupt.c:54
@@ +53,3 @@
+  foo8((int *)argv);   // expected-error {{interrupt service routine can't 
be used directly}}
+  return 0;
+}

aaron.ballman wrote:
> I'd like to see a test like:
> ```
> __attribute__((interrupt)) void foo8(int *a) {}
> 
> void g(void (*fp)(int *));
> 
> void f() {
>   g(foo8);
> }
> ```
> as I think this is supposed to diagnose. It might also be good to have a 
> similar test using templates in C++.
Checked again. I did not look at the code for a long time and just forgot that 
the functions cannot be called, but you can take their address. Modified the 
message and the code itself for better check.


http://reviews.llvm.org/D15709



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


Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-29 Thread Alexey Bataev via cfe-commits
ABataev updated this revision to Diff 43727.
ABataev added a comment.

Update after review


http://reviews.llvm.org/D15709

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/attr-x86-interrupt.c
  test/CodeGenCXX/attr-x86-interrupt.cpp
  test/Sema/attr-x86-interrupt.c
  test/SemaCXX/attr-x86-interrupt.cpp

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1609,6 +1609,10 @@
   llvm::AttributeSet::FunctionIndex,
   B));
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
   }
 }
 
@@ -1914,6 +1918,16 @@
 ('T' << 24);
 return llvm::ConstantInt::get(CGM.Int32Ty, Sig);
   }
+
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule &CGM) const override {
+if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+  }
+}
+  }
 };
 
 class PS4TargetCodeGenInfo : public X86_64TargetCodeGenInfo {
@@ -2031,6 +2045,13 @@
 CodeGen::CodeGenModule &CGM) const {
   TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
 
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
+  }
+
   addStackProbeSizeTargetAttribute(D, GV, CGM);
 }
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5035,6 +5035,12 @@
   FunctionDecl *FDecl = dyn_cast_or_null(NDecl);
   unsigned BuiltinID = (FDecl ? FDecl->getBuiltinID() : 0);
 
+  // Functions with 'interrupt' attribute cannot be called directly.
+  if (FDecl && FDecl->hasAttr()) {
+Diag(Fn->getExprLoc(), diag::err_interrupt_function_called);
+return ExprError();
+  }
+
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
   // builtin functions to function pointers in the callee of a call.
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4545,17 +4545,74 @@
   Attr.getLoc(), S.Context, Kind, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAnyX86InterruptAttr(Sema &S, Decl *D,
+  const AttributeList &Attr) {
+  // Semantic checks for a function with the 'interrupt' attribute.
+  // a) Must be a function.
+  // b) Must have the 'void' return type.
+  // c) Must take 1 or 2 arguments.
+  // d) The 1st argument must be a pointer.
+  // e) The 2nd argument (if any) must be an unsigned integer.
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) ||
+  !D->getDeclContext()->isFileContext()) {
+S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+<< Attr.getName() << ExpectedFunctionWithProtoType;
+return;
+  }
+  // Interrupt handler must have void return type.
+  if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+S.Diag(getFunctionOrMethodResultSourceRange(D).getBegin(),
+   diag::err_interrupt_function_wrong_return_type);
+return;
+  }
+  // Interrupt handler must have 1 or 2 parameters.
+  unsigned NumParams = getFunctionOrMethodNumParams(D);
+  if (NumParams < 1 || NumParams > 2) {
+S.Diag(D->getLocStart(), diag::err_interrupt_function_wrong_args);
+return;
+  }
+  // The first argument must be a pointer.
+  if (!getFunctionOrMethodParamType(D, 0)->isPointerType()) {
+S.Diag(getFunctionOrMethodParamRange(D, 0).getBegin(),
+   diag::err_interrupt_function_wrong_first_arg);
+return;
+  }
+  // The second argument, if present, must be an unsigned integer.
+  unsigned TypeSize =
+  S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64
+  ? 64
+  : 32;
+  if (NumParams == 2 &&
+  (!getFunctionOrMethodParamType(D, 1)->isUnsignedIntegerType() ||
+   S.Context.getTypeSize(getFunctionOrMethodParamType(D, 1)) != TypeSize)) {
+S.Diag(getFunctionOrMethodParamRange(D, 1).getBegin(),
+   diag::err_interrupt_function_wrong_second_arg)
+<< S.Context.getIntTypeForBitwidth(TypeSize, /*Signed=*/false);
+return;
+  }
+  D->addAttr(::new (S.Context) AnyX86InterruptAttr(
+  Attr.getLoc(), S.Context, Attr.getAttributeSpellingListIndex()));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
+}
+
 static void handl

Re: [PATCH] D15803: [clang-tidy] Don't generate duplicated blank line in add_new_check.py script.

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. I'll submit the patch for you.


Repository:
  rL LLVM

http://reviews.llvm.org/D15803



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


[clang-tools-extra] r256554 - [clang-tidy] Don't generate duplicated blank line in add_new_check.py script.

2015-12-29 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Dec 29 05:05:35 2015
New Revision: 256554

URL: http://llvm.org/viewvc/llvm-project?rev=256554&view=rev
Log:
[clang-tidy] Don't generate duplicated blank line in add_new_check.py script.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by Haojian Wu!

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

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=256554&r1=256553&r2=256554&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Tue Dec 29 05:05:35 2015
@@ -92,7 +92,6 @@ public:
 } // namespace clang
 
 #endif // %(header_guard)s
-
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
@@ -146,7 +145,6 @@ void %(check_name)s::check(const MatchFi
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-
 """ % {'check_name': check_name_camel,
'module': module})
 


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


Re: [PATCH] D15803: [clang-tidy] Don't generate duplicated blank line in add_new_check.py script.

2015-12-29 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256554: [clang-tidy] Don't generate duplicated blank line in 
add_new_check.py script. (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D15803?vs=43717&id=43728#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15803

Files:
  clang-tools-extra/trunk/clang-tidy/add_new_check.py

Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -92,7 +92,6 @@
 } // namespace clang
 
 #endif // %(header_guard)s
-
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
@@ -146,7 +145,6 @@
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-
 """ % {'check_name': check_name_camel,
'module': module})
 


Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -92,7 +92,6 @@
 } // namespace clang
 
 #endif // %(header_guard)s
-
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
@@ -146,7 +145,6 @@
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-
 """ % {'check_name': check_name_camel,
'module': module})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r256517 - Orphaning these RST files; each one is retained only for link backwards compatibility.

2015-12-29 Thread Alexander Kornienko via cfe-commits
Nice! Didn't know about this feature.

On Mon, Dec 28, 2015 at 8:59 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Mon Dec 28 13:59:15 2015
> New Revision: 256517
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256517&view=rev
> Log:
> Orphaning these RST files; each one is retained only for link backwards
> compatibility.
>
> Modified:
> clang-tools-extra/trunk/docs/clang-modernize.rst
> clang-tools-extra/trunk/docs/clang-tidy.rst
> clang-tools-extra/trunk/docs/cpp11-migrate.rst
>
> Modified: clang-tools-extra/trunk/docs/clang-modernize.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-modernize.rst?rev=256517&r1=256516&r2=256517&view=diff
>
> ==
> --- clang-tools-extra/trunk/docs/clang-modernize.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-modernize.rst Mon Dec 28 13:59:15
> 2015
> @@ -1,2 +1,4 @@
> +:orphan:
> +
>  All :program:`clang-modernize` transforms have moved to
> :doc:`clang-tidy/index`
>  (see the ``modernize`` module).
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy.rst?rev=256517&r1=256516&r2=256517&view=diff
>
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy.rst Mon Dec 28 13:59:15 2015
> @@ -1,3 +1,5 @@
> +:orphan:
> +
>  .. meta::
> :http-equiv=refresh: 0;URL='http://clang.llvm.org/extra/clang-tidy/'
>
>
> Modified: clang-tools-extra/trunk/docs/cpp11-migrate.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/cpp11-migrate.rst?rev=256517&r1=256516&r2=256517&view=diff
>
> ==
> --- clang-tools-extra/trunk/docs/cpp11-migrate.rst (original)
> +++ clang-tools-extra/trunk/docs/cpp11-migrate.rst Mon Dec 28 13:59:15 2015
> @@ -1,2 +1,4 @@
> +:orphan:
> +
>  All :program:`clang-modernize` transforms have moved to
> :doc:`clang-tidy/index`
>  (see the ``modernize`` module).
>
>
> ___
> 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


r256555 - [MS ABI] Cleanup the mangling of artifical types

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 05:45:53 2015
New Revision: 256555

URL: http://llvm.org/viewvc/llvm-project?rev=256555&view=rev
Log:
[MS ABI] Cleanup the mangling of artifical types

Hand-rolling the mangling results in us not correctly adding names to
the backreference map.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256555&r1=256554&r2=256555&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 05:45:53 2015
@@ -263,6 +263,9 @@ public:
   const CXXMethodDecl *MD,
   const MicrosoftVTableContext::MethodVFTableLocation &ML);
   void mangleNumber(int64_t Number);
+  void mangleTagTypeKind(TagTypeKind TK);
+  void mangleArtificalTagType(TagTypeKind TK, StringRef UnqualifiedName,
+  ArrayRef NestedNames = None);
   void mangleType(QualType T, SourceRange Range,
   QualifierMangleMode QMM = QMM_Mangle);
   void mangleFunctionType(const FunctionType *T,
@@ -1136,12 +1139,6 @@ void MicrosoftCXXNameMangler::mangleExpr
 UE = dyn_cast(E);
 
   if (UE) {
-// This CXXUuidofExpr is mangled as-if it were actually a VarDecl from
-// const __s_GUID _GUID_{lower case UUID with underscores}
-StringRef Uuid = UE->getUuidAsStringRef(Context.getASTContext());
-std::string Name = "_GUID_" + Uuid.lower();
-std::replace(Name.begin(), Name.end(), '-', '_');
-
 // If we had to peek through an address-of operator, treat this like we are
 // dealing with a pointer type.  Otherwise, treat it like a const 
reference.
 //
@@ -1151,7 +1148,22 @@ void MicrosoftCXXNameMangler::mangleExpr
   Out << "$E?";
 else
   Out << "$1?";
-Out << Name << "@@3U__s_GUID@@B";
+
+// This CXXUuidofExpr is mangled as-if it were actually a VarDecl from
+// const __s_GUID _GUID_{lower case UUID with underscores}
+StringRef Uuid = UE->getUuidAsStringRef(Context.getASTContext());
+std::string Name = "_GUID_" + Uuid.lower();
+std::replace(Name.begin(), Name.end(), '-', '_');
+
+mangleSourceName(Name);
+// Terminate the whole name with an '@'.
+Out << '@';
+// It's a global variable.
+Out << '3';
+// It's a struct called __s_GUID.
+mangleArtificalTagType(TTK_Struct, "__s_GUID");
+// It's const.
+Out << 'B';
 return;
   }
 
@@ -1637,68 +1649,89 @@ void MicrosoftCXXNameMangler::mangleType
 llvm_unreachable("placeholder types shouldn't get to name mangling");
 
   case BuiltinType::ObjCId:
-Out << "PAUobjc_object@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "objc_object");
 break;
   case BuiltinType::ObjCClass:
-Out << "PAUobjc_class@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "objc_class");
 break;
   case BuiltinType::ObjCSel:
-Out << "PAUobjc_selector@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "objc_selector");
 break;
 
   case BuiltinType::OCLImage1d:
-Out << "PAUocl_image1d@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image1d");
 break;
   case BuiltinType::OCLImage1dArray:
-Out << "PAUocl_image1darray@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image1darray");
 break;
   case BuiltinType::OCLImage1dBuffer:
-Out << "PAUocl_image1dbuffer@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image1dbuffer");
 break;
   case BuiltinType::OCLImage2d:
-Out << "PAUocl_image2d@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2d");
 break;
   case BuiltinType::OCLImage2dArray:
-Out << "PAUocl_image2darray@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2darray");
 break;
   case BuiltinType::OCLImage2dDepth:
-Out << "PAUocl_image2ddepth@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2ddepth");
 break;
   case BuiltinType::OCLImage2dArrayDepth:
-Out << "PAUocl_image2darraydepth@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2darraydepth");
 break;
   case BuiltinType::OCLImage2dMSAA:
-Out << "PAUocl_image2dmsaa@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2dmsaa");
 break;
   case BuiltinType::OCLImage2dArrayMSAA:
-Out << "PAUocl_image2darraymsaa@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2darraymsaa");
 break;
   case BuiltinType::OCLImage2dMSAADepth:
-Out << "PAUocl_image2dmsaadepth@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2dmsaadepth");
 break;
   case BuiltinType::OCLImage2dArrayMSAADepth:
-Out << "PAUocl_image2darraymsaadepth@@";
+Out << "PA";
+mangleArtificalTagType(TTK_Struct, "ocl_image2darraymsaadepth");
   

r256556 - [MS ABI] Cleanup our mangling of vector types

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 05:45:58 2015
New Revision: 256556

URL: http://llvm.org/viewvc/llvm-project?rev=256556&view=rev
Log:
[MS ABI] Cleanup our mangling of vector types

We used to produce a type which demangled to:
union __clang_vec8_F

That 'F' is the mangling for 'short' but it is present in the mangled
name in an inappropriate place, leading to it not getting demangled.

Instead, create a synthetic class type in a synthetic namespace called
__clang. With this, it now demangles to:
union __clang::__vector

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256556&r1=256555&r2=256556&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 05:45:58 2015
@@ -2227,7 +2227,7 @@ void MicrosoftCXXNameMangler::mangleType
   uint64_t Width = getASTContext().getTypeSize(T);
   // Pattern match exactly the typedefs in our intrinsic headers.  Anything 
that
   // doesn't match the Intel types uses a custom mangling below.
-  bool IsBuiltin = true;
+  size_t OutSizeBefore = Out.tell();
   llvm::Triple::ArchType AT =
   getASTContext().getTargetInfo().getTriple().getArch();
   if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
@@ -2240,22 +2240,25 @@ void MicrosoftCXXNameMangler::mangleType
 mangleArtificalTagType(TTK_Union, "__m" + llvm::utostr(Width) + 'i');
   else if (ET->getKind() == BuiltinType::Double)
 mangleArtificalTagType(TTK_Struct, "__m" + llvm::utostr(Width) + 'd');
-  else
-IsBuiltin = false;
-} else {
-  IsBuiltin = false;
 }
-  } else {
-IsBuiltin = false;
   }
 
+  bool IsBuiltin = Out.tell() != OutSizeBefore;
   if (!IsBuiltin) {
 // The MS ABI doesn't have a special mangling for vector types, so we 
define
 // our own mangling to handle uses of __vector_size__ on user-specified
 // types, and for extensions like __v4sf.
-Out << "T__clang_vec" << T->getNumElements() << '_';
-mangleType(ET, Quals, Range);
-Out << "@@";
+
+llvm::SmallString<64> TemplateMangling;
+llvm::raw_svector_ostream Stream(TemplateMangling);
+MicrosoftCXXNameMangler Extra(Context, Stream);
+Stream << "?$";
+Extra.mangleSourceName("__vector");
+Extra.mangleType(QualType(ET, 0), Range, QMM_Escape);
+Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumElements()),
+   /*IsBoolean=*/false);
+
+mangleArtificalTagType(TTK_Union, TemplateMangling, {"__clang"});
   }
 }
 

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp?rev=256556&r1=256555&r2=256556&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-vector-types.cpp Tue Dec 29 05:45:58 
2015
@@ -27,11 +27,11 @@ void foo256i(__m256i) {}
 
 // We have a custom mangling for vector types not standardized by Intel.
 void foov8hi(__v8hi) {}
-// CHECK: define void @"\01?foov8hi@@YAXT__clang_vec8_F@@@Z"
+// CHECK: define void @"\01?foov8hi@@YAXT?$__vector@F$07@__clang@@@Z"
 
 typedef __attribute__((ext_vector_type(4))) int vi4b;
 void foovi4b(vi4b) {}
-// CHECK: define void @"\01?foovi4b@@YAXT__clang_vec4_H@@@Z"
+// CHECK: define void @"\01?foovi4b@@YAXT?$__vector@H$03@__clang@@@Z"
 
 // Clang does not support vectors of complex types, so we can't test the
 // mangling of them.


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


r256557 - [MS ABI] Implement a mangling for _Atomic types

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 05:46:00 2015
New Revision: 256557

URL: http://llvm.org/viewvc/llvm-project?rev=256557&view=rev
Log:
[MS ABI] Implement a mangling for _Atomic types

MSVC doesn't implement a mangling for C11's _Atomic so we must invent
our own.

For now, treating it like a class type called _Atomic in the __clang
namespace.

This means that 'void f(__Atomic(int))'
will demangle as: 'void f(struct __clang::_Atomic)'

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256557&r1=256556&r2=256557&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 05:46:00 2015
@@ -2391,11 +2391,16 @@ void MicrosoftCXXNameMangler::mangleType
 
 void MicrosoftCXXNameMangler::mangleType(const AtomicType *T, Qualifiers,
  SourceRange Range) {
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this C11 atomic type yet");
-  Diags.Report(Range.getBegin(), DiagID)
-<< Range;
+  QualType ValueType = T->getValueType();
+
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+  Stream << "?$";
+  Extra.mangleSourceName("_Atomic");
+  Extra.mangleType(ValueType, Range, QMM_Escape);
+
+  mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }
 
 void MicrosoftMangleContextImpl::mangleCXXName(const NamedDecl *D,

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=256557&r1=256556&r2=256557&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Tue Dec 29 05:46:00 2015
@@ -437,3 +437,8 @@ int foo(int *const i __attribute__((pass
 // CHECK-DAG: define i32 
@"\01?bar@PassObjectSize@@YAHQAHW4__pass_object_size1@__clang@@@Z"
 int bar(int *const i __attribute__((pass_object_size(1 { return 0; }
 }
+
+namespace Atomic {
+// CHECK-DAG: define void @"\01?f@Atomic@@YAXU?$_Atomic@H@__clang@@@Z"(
+void f(_Atomic(int)) {}
+}


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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/google/DefinitionsInHeadersCheck.cpp:52
@@ +51,3 @@
+// Inline function is allowed.
+if (funDecl->isInlined())
+  return;

hokein wrote:
> alexfh wrote:
> > This check can be done in the matcher.
> The `isInline` AST matcher seems only match the function with `inline` key 
> words. It could not detect the member function defined within class, such as:
> 
> ```
> class A {
>   int f() { return 1; }
> };
> ```
Yep, I've found this out myself, but have forgotten to remove the comment.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:23
@@ +22,3 @@
+bool inHeaderFile(const SourceManager *SM, SourceLocation Location) {
+  StringRef Filename = SM->getFilename(SM->getExpansionLoc(Location));
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||

I don't think "main file" is the right condition here. If we run clang-tidy on 
a header file, it will be the main file, but we still are interested in the 
diagnostics in it. So I don't see a better way to distinguish header files than 
looking at their extension (some projects might need the list of extensions to 
be configurable, but that's another story).


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:31
@@ +30,3 @@
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  decl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition(

Do you expect this to improve performance?


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:47
@@ +46,3 @@
+  const auto *ND = Result.Nodes.getNodeAs("decl");
+  if (!ND)
+return;

I'd replace this with an assertion, since this bound node should always be a 
`NamedDecl`. To make this explicit, I'd also use the `namedDecl` matcher 
instead of `decl` above.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:53
@@ +52,3 @@
+  //   const int a = 1;
+  //   static int a = 1;
+  //   namespace {

nit: Use of the same variable name distracts from the essence of the example. 
Please use unique variable names.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:56
@@ +55,3 @@
+  // int a = 1;
+  // int f() { return 1}
+  //   }

nit: Missing `; ` after `1`.


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:2
@@ +1,3 @@
+misc-definitions-in-headers
+=
+

nit: Please remove two `=`'s.


Comment at: unittests/clang-tidy/GoogleModuleTest.cpp:140
@@ +139,3 @@
+ "}", "foo.h"));
+  EXPECT_EQ(errorMessage, runCheckOnCode("template \n"
+ "T f() {\n"

hokein wrote:
> alexfh wrote:
> > I think, we can already use raw string literals (at least, MSVC 2013 seems 
> > to support them). Raw string literals would make the test cases more 
> > readable, imo.
> The Raw string literals doesn't work well with multiple lines in macro. I try 
> it on my local machine, it will break compilation.
> 
You mean, the `EXPECT_EQ` macro doesn't work with raw string literals somehow? 
That sounds strange.


Comment at: unittests/clang-tidy/MiscModuleTest.cpp:38
@@ -36,1 +37,3 @@
 
+class DefinitionsInHeadersCheckTest : public ::testing::Test {
+protected:

aaron.ballman wrote:
> hokein wrote:
> > I'm not sure about this. The reason I put the test in unittest is that I 
> > see the other header checks(`GlobalNamesInHeadersCheck`) are also in the 
> > unittest. It would be better to keep the consistency.
> I was arguing for consistency as well -- clang-tidy tests are run via lit 
> instead of unit tests unless there's a reason to do otherwise. It sounds like 
> there's no reason for these to be unit tests.
I don't feel strongly about this, but I generally prefer lit tests as well, 
since they allow to test both messages and fixes easily and with less 
boilerplate. It's true, that setting up a test case with multiple header files 
may be somewhat easier in a unit test (where everything is described in a 
single place), but this doesn't seem to be the case.

Once you start testing fixits, a lit test will immediately become a simpler 
solution.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15805: [clang-tidy] Cleanup code in CERT module.

2015-12-29 Thread Haojian Wu via cfe-commits
hokein added a comment.

I'm wondering whether should we rename  `CERT` to `cert` to keep the same with 
other modules like misc and google.
For adding a new check in CERT module, you need to use the upper name 
explicitly via `python add_new_check.py CERT foo` rather than `python 
add_new_check.py cert foo`.


Repository:
  rL LLVM

http://reviews.llvm.org/D15805



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


Re: [PATCH] D15623: Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for working on this!

A few minor comments.



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ +20,3 @@
+namespace {
+AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
+AST_MATCHER(QualType, isPointerType) { return Node->isPointerType(); }

Maybe move this to clang-tidy/utils/Matchers.h?


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:24
@@ +23,3 @@
+
+Token getPreviousNonCommentToken(const ASTContext &Context,
+ SourceLocation Location) {

This might be useful elsewhere. Let's move it to clang-tidy/utils/LexerUtils.h 
/ .cpp.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:16
@@ +15,3 @@
+namespace clang {
+namespace tidy {
+

This should also be in the `performance` namespace. The `add_new_check.py` 
script has been fixed in the meantime.


http://reviews.llvm.org/D15623



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


Re: [PATCH] D15805: [clang-tidy] Cleanup code in CERT module.

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D15805#317629, @hokein wrote:

> I'm wondering whether should we rename  `CERT` to `cert` to keep the same 
> with other modules like misc and google.


SGTM. Aaron, do you see any reasons not to do this?


Repository:
  rL LLVM

http://reviews.llvm.org/D15805



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


[clang-tools-extra] r256559 - [clang-tidy] Fix capitalization of the message in the example

2015-12-29 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Dec 29 07:28:10 2015
New Revision: 256559

URL: http://llvm.org/viewvc/llvm-project?rev=256559&view=rev
Log:
[clang-tidy] Fix capitalization of the message in the example

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=256559&r1=256558&r2=256559&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Tue Dec 29 07:28:10 2015
@@ -346,7 +346,7 @@ can further inspect them and report diag
 if (Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1)
   return;
 SourceLocation Loc = Ctor->getLocation();
-diag(Loc, "Single-argument constructors must be explicit")
+diag(Loc, "single-argument constructors must be explicit")
 << FixItHint::CreateInsertion(Loc, "explicit ");
   }
 


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


Re: [PATCH] D15791: Disable generating movt on FreeBSD

2015-12-29 Thread Davide Italiano via cfe-commits
davide added a comment.

In http://reviews.llvm.org/D15791#317172, @dim wrote:

> @davide, any idea whether lld will be able to handle movt correctly?  If so, 
> we might want to make this dependent on `-fuse-ld=bfd` or `-fuse-ld=lld` ?


lld/AArch64 can't still handle that properly, so I'd rather recommend to make 
it dependent on fuse-ld=bfd.

Thanks,

-

Davide


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


Re: [PATCH] D15805: [clang-tidy] Cleanup code in CERT module.

2015-12-29 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.

Fine by me -- I went with CERT since it's an acronym, but we don't do this for 
LLVM, so this change makes sense. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D15805



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


Re: [PATCH] D15685: [clang-tidy] introducing cppcoreguidelines-enum-all-caps check

2015-12-29 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@alexfh, Thanks for the feedback!

What you said seems reasonable to me, I'll follow your advice and come up with 
the proposed solution!


http://reviews.llvm.org/D15685



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:23
@@ +22,3 @@
+bool inHeaderFile(const SourceManager *SM, SourceLocation Location) {
+  StringRef Filename = SM->getFilename(SM->getExpansionLoc(Location));
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||

alexfh wrote:
> I don't think "main file" is the right condition here. If we run clang-tidy 
> on a header file, it will be the main file, but we still are interested in 
> the diagnostics in it. So I don't see a better way to distinguish header 
> files than looking at their extension (some projects might need the list of 
> extensions to be configurable, but that's another story).
I would argue that if you run clang-tidy on just the header file, you might 
know what you are doing and expect to not see those diagnostics at all.

Relying on the extension makes this far less useful, IMO. For instance, even on 
this second try, the checker will fail to catch ODR violations in STL-style 
header files. You can #include "file.cpp" just as easily as "file.h" (as we do 
with .inc files, for instance), and that can still result in ODR violations 
too. To me, the extension isn't what makes this checker do interesting work, 
it's the fact that these can only be violations when the file is included in 
multiple TUs (except we can only check one TU at a time, so looking for the 
file to be included is the best we can do). 


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:31
@@ +30,3 @@
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  decl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition(

alexfh wrote:
> Do you expect this to improve performance?
Possibly improve performance (I would suspect there are a lot of varDecls and a 
fair number of functionDecls in the main file), but I also prefer the checkers 
to be as declarative as possible. It makes it easier (at least for me) to 
reason about what AST nodes the check is ultimately interested in.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15791: Disable generating movt on FreeBSD

2015-12-29 Thread Davide Italiano via cfe-commits
davide accepted this revision.
davide added a reviewer: davide.
davide added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: lib/Driver/Tools.cpp:941
@@ -940,3 +940,3 @@
 
-  // The kext linker doesn't know how to deal with movw/movt.
-  if (KernelOrKext)
+  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
+  if (KernelOrKext || Triple.isOSFreeBSD())

I'd add a FIXME I expect this to be fixed in the foreseeable future.


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

Since this is not a deprecated/obsolete file, it might be a good idea to also 
add a textual redirection with native RST links for media not supporting HTTP 
redirects (e.g. PDF or whatever else can be generated from the RST files).


Comment at: docs/clang-tidy/checks/google-build-namespaces.rst:6
@@ -5,2 +5,3 @@
 
+Aliases: cert-dcl59-cpp
 

nit: Missing trailing period.

Also, it might be a good idea to make this slightly more verbose, e.g. 
s/Aliases/This check is available under the following names/ or something like 
this.


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

alexfh wrote:
> Since this is not a deprecated/obsolete file, it might be a good idea to also 
> add a textual redirection with native RST links for media not supporting HTTP 
> redirects (e.g. PDF or whatever else can be generated from the RST files).
So basically use a regular link instead of the meta redirect?


Comment at: docs/clang-tidy/checks/google-build-namespaces.rst:6
@@ -5,2 +5,3 @@
 
+Aliases: cert-dcl59-cpp
 

alexfh wrote:
> nit: Missing trailing period.
> 
> Also, it might be a good idea to make this slightly more verbose, e.g. 
> s/Aliases/This check is available under the following names/ or something 
> like this.
Agreed.


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:23
@@ +22,3 @@
+bool inHeaderFile(const SourceManager *SM, SourceLocation Location) {
+  StringRef Filename = SM->getFilename(SM->getExpansionLoc(Location));
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||

aaron.ballman wrote:
> alexfh wrote:
> > I don't think "main file" is the right condition here. If we run clang-tidy 
> > on a header file, it will be the main file, but we still are interested in 
> > the diagnostics in it. So I don't see a better way to distinguish header 
> > files than looking at their extension (some projects might need the list of 
> > extensions to be configurable, but that's another story).
> I would argue that if you run clang-tidy on just the header file, you might 
> know what you are doing and expect to not see those diagnostics at all.
> 
> Relying on the extension makes this far less useful, IMO. For instance, even 
> on this second try, the checker will fail to catch ODR violations in 
> STL-style header files. You can #include "file.cpp" just as easily as 
> "file.h" (as we do with .inc files, for instance), and that can still result 
> in ODR violations too. To me, the extension isn't what makes this checker do 
> interesting work, it's the fact that these can only be violations when the 
> file is included in multiple TUs (except we can only check one TU at a time, 
> so looking for the file to be included is the best we can do). 
> I would argue that if you run clang-tidy on just the header file, you might 
> know what you are doing and expect to not see those diagnostics at all.

I don't agree here. What one runs the check on is a purely technical detail. It 
may be even hidden from the user by tooling (e.g. editor or code review 
integration).

> Relying on the extension makes this far less useful, IMO. For instance, even 
> on this second try, the checker will fail to catch ODR violations in 
> STL-style 
> header files.

We can make it work for STL-style header files by treating extensionless files 
as headers. Or make this filter a regular expression or something like that.

> You can #include "file.cpp" just as easily as "file.h" (as we do with .inc 
> files, for instance), and that can still result in ODR violations too.

We don't usually include `.cpp` files. And the `.inc` extension says the file 
is a textual include and usually can't be parsed on its own. And it's very 
uncommon to actually compile `.h` files on their own as a part of the build. So 
I'm inclined to treat the file extension as a valuable piece of information 
regarding its intended use.

> To me, the extension isn't what makes this checker do interesting work, it's 
> the 
> fact that these can only be violations when the file is included in multiple 
> TUs 

If someone includes a ".cpp" file, it's a problem, but, IMO, detection of 
actually present ODR violations is a task for a different tool (possibly, 
another clang-tidy check, once we have multi-translation-unit support). This 
check's purpose is to detect a certain class of issues that can potentially 
cause ODR violations.

> (except we can only check one TU at a time, so looking for the file to be 
> included is the best we can do).

We can do even better by utilizing the information we already have in the file 
name. Do you see any specific issues that can result from this?


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:31
@@ +30,3 @@
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  decl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition(

aaron.ballman wrote:
> alexfh wrote:
> > Do you expect this to improve performance?
> Possibly improve performance (I would suspect there are a lot of varDecls and 
> a fair number of functionDecls in the main file), but I also prefer the 
> checkers to be as declarative as possible. It makes it easier (at least for 
> me) to reason about what AST nodes the check is ultimately interested in.
As noted above, "main file" is not a useful condition here. However, it's 
certainly possible to move some of the checks from the `check` method to 
matcher(s) (e.g. `isLocationInHeaderFile`). I don't feel strongly about that.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

aaron.ballman wrote:
> alexfh wrote:
> > Since this is not a deprecated/obsolete file, it might be a good idea to 
> > also add a textual redirection with native RST links for media not 
> > supporting HTTP redirects (e.g. PDF or whatever else can be generated from 
> > the RST files).
> So basically use a regular link instead of the meta redirect?
I'd use either a regular link, or both a link and the redirect.


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

alexfh wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > Since this is not a deprecated/obsolete file, it might be a good idea to 
> > > also add a textual redirection with native RST links for media not 
> > > supporting HTTP redirects (e.g. PDF or whatever else can be generated 
> > > from the RST files).
> > So basically use a regular link instead of the meta redirect?
> I'd use either a regular link, or both a link and the redirect.
One interesting aspect to consider is the bingability of check names, e.g. 
http://www.bing.com/search?q=google-build-namespaces or 
http://www.google.com/search?q=misc-new-delete-overloads (apparently, this one 
doesn't work well with bing).

I'm not sure redirects will play well with it, but we can try. Inclusion of the 
checks in the index seems like the must though, if we want the checks to be 
searchable.


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:23
@@ +22,3 @@
+bool inHeaderFile(const SourceManager *SM, SourceLocation Location) {
+  StringRef Filename = SM->getFilename(SM->getExpansionLoc(Location));
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||

alexfh wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > I don't think "main file" is the right condition here. If we run 
> > > clang-tidy on a header file, it will be the main file, but we still are 
> > > interested in the diagnostics in it. So I don't see a better way to 
> > > distinguish header files than looking at their extension (some projects 
> > > might need the list of extensions to be configurable, but that's another 
> > > story).
> > I would argue that if you run clang-tidy on just the header file, you might 
> > know what you are doing and expect to not see those diagnostics at all.
> > 
> > Relying on the extension makes this far less useful, IMO. For instance, 
> > even on this second try, the checker will fail to catch ODR violations in 
> > STL-style header files. You can #include "file.cpp" just as easily as 
> > "file.h" (as we do with .inc files, for instance), and that can still 
> > result in ODR violations too. To me, the extension isn't what makes this 
> > checker do interesting work, it's the fact that these can only be 
> > violations when the file is included in multiple TUs (except we can only 
> > check one TU at a time, so looking for the file to be included is the best 
> > we can do). 
> > I would argue that if you run clang-tidy on just the header file, you might 
> > know what you are doing and expect to not see those diagnostics at all.
> 
> I don't agree here. What one runs the check on is a purely technical detail. 
> It may be even hidden from the user by tooling (e.g. editor or code review 
> integration).
> 
> > Relying on the extension makes this far less useful, IMO. For instance, 
> > even 
> > on this second try, the checker will fail to catch ODR violations in 
> > STL-style 
> > header files.
> 
> We can make it work for STL-style header files by treating extensionless 
> files as headers. Or make this filter a regular expression or something like 
> that.
> 
> > You can #include "file.cpp" just as easily as "file.h" (as we do with .inc 
> > files, for instance), and that can still result in ODR violations too.
> 
> We don't usually include `.cpp` files. And the `.inc` extension says the file 
> is a textual include and usually can't be parsed on its own. And it's very 
> uncommon to actually compile `.h` files on their own as a part of the build. 
> So I'm inclined to treat the file extension as a valuable piece of 
> information regarding its intended use.
> 
> > To me, the extension isn't what makes this checker do interesting work, 
> > it's the 
> > fact that these can only be violations when the file is included in 
> > multiple TUs 
> 
> If someone includes a ".cpp" file, it's a problem, but, IMO, detection of 
> actually present ODR violations is a task for a different tool (possibly, 
> another clang-tidy check, once we have multi-translation-unit support). This 
> check's purpose is to detect a certain class of issues that can potentially 
> cause ODR violations.
> 
> > (except we can only check one TU at a time, so looking for the file to be 
> > included is the best we can do).
> 
> We can do even better by utilizing the information we already have in the 
> file name. Do you see any specific issues that can result from this?
>> You can #include "file.cpp" just as easily as "file.h" (as we do with .inc 
>> files, for instance), and that can still result in ODR violations too.
> We don't usually include .cpp files. And the .inc extension says the file is 
> a textual include and usually can't be parsed on its own. And it's very 
> uncommon to actually compile .h files on their own as a part of the build. So 
> I'm inclined to treat the file extension as a valuable piece of information 
> regarding its intended use.

The point I was getting at is that an extension is arbitrary, though somewhat 
conventionally-named. I don't see it as being particularly valuable in this 
case because "has this file been included" is sufficient information to 
determine whether we want to diagnose or not. I guess that these arguments all 
boil down to which is more likely to happen: a header file with an extension we 
don't capture (because user's aren't going to *know* to customize the header 
file extension list, generally), or the user running this checker on just the 
header file, but never a source file that includes the header file. While I can 
think of cases where the user runs it on just the header file, they seem few 
and far between.

Perhaps another solution to this is use isInMainFile() || 
usesHeaderFileExtension().

> We can do even better by utilizing the information we already have in the 
> file n

[clang-tools-extra] r256562 - [clang-tidy] Fix a use-after-free bug found by asan

2015-12-29 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Dec 29 10:14:38 2015
New Revision: 256562

URL: http://llvm.org/viewvc/llvm-project?rev=256562&view=rev
Log:
[clang-tidy] Fix a use-after-free bug found by asan

Modified:
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=256562&r1=256561&r2=256562&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
Tue Dec 29 10:14:38 2015
@@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(con
 bool containsDiscardedTokens(
 const ast_matchers::MatchFinder::MatchResult &Result,
 CharSourceRange CharRange) {
-  StringRef ReplacementText =
+  std::string ReplacementText =
   Lexer::getSourceText(CharRange, *Result.SourceManager,
-   Result.Context->getLangOpts()).str();
+   Result.Context->getLangOpts())
+  .str();
   Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
 ReplacementText.data(), ReplacementText.data(),
 ReplacementText.data() + ReplacementText.size());


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


Re: [clang-tools-extra] r256562 - [clang-tidy] Fix a use-after-free bug found by asan

2015-12-29 Thread Benjamin Kramer via cfe-commits
On Tue, Dec 29, 2015 at 5:14 PM, Alexander Kornienko via cfe-commits
 wrote:
> Author: alexfh
> Date: Tue Dec 29 10:14:38 2015
> New Revision: 256562
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256562&view=rev
> Log:
> [clang-tidy] Fix a use-after-free bug found by asan
>
> Modified:
> 
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>
> Modified: 
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=256562&r1=256561&r2=256562&view=diff
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
> (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
> Tue Dec 29 10:14:38 2015
> @@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(con
>  bool containsDiscardedTokens(
>  const ast_matchers::MatchFinder::MatchResult &Result,
>  CharSourceRange CharRange) {
> -  StringRef ReplacementText =
> +  std::string ReplacementText =
>Lexer::getSourceText(CharRange, *Result.SourceManager,
> -   Result.Context->getLangOpts()).str();
> +   Result.Context->getLangOpts())
> +  .str();

Can you just drop the .str() and change the type back to StringRef?

- Ben

>Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
>  ReplacementText.data(), ReplacementText.data(),
>  ReplacementText.data() + ReplacementText.size());
>
>
> ___
> 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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

alexfh wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > Since this is not a deprecated/obsolete file, it might be a good idea 
> > > > to also add a textual redirection with native RST links for media not 
> > > > supporting HTTP redirects (e.g. PDF or whatever else can be generated 
> > > > from the RST files).
> > > So basically use a regular link instead of the meta redirect?
> > I'd use either a regular link, or both a link and the redirect.
> One interesting aspect to consider is the bingability of check names, e.g. 
> http://www.bing.com/search?q=google-build-namespaces or 
> http://www.google.com/search?q=misc-new-delete-overloads (apparently, this 
> one doesn't work well with bing).
> 
> I'm not sure redirects will play well with it, but we can try. Inclusion of 
> the checks in the index seems like the must though, if we want the checks to 
> be searchable.
I think a link and the redirect make sense. Would a 5 second delay be a 
reasonable amount of time before the auto redirect?

Also, the more I think on it, the more I agree that we want the checks in the 
index file. I think it might be best to make the aliases visually distinct, 
though. So perhaps something like:

cert-dcl54-cpp (alias to misc-new-delete-overloads)

And then have the link go directly to misc-new-delete-overloads instead of 
making them click through or wait for the redirect?


http://reviews.llvm.org/D15796



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


r256564 - [TrailingObjects] Use a different technique to determine if a getDecl

2015-12-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Dec 29 10:44:11 2015
New Revision: 256564

URL: http://llvm.org/viewvc/llvm-project?rev=256564&view=rev
Log:
[TrailingObjects] Use a different technique to determine if a getDecl
member function exists on a class.

The previous trick depended on inheriting from the class it was
checking, which will fail when I start marking things 'final'.

Attempt #2: now with a special #ifdef branch for MSVC.

Hopefully *this* actually builds with all supported compilers...

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=256564&r1=256563&r2=256564&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue Dec 29 
10:44:11 2015
@@ -558,22 +558,32 @@ bool matchesFirstInPointerRange(const Ma
   return false;
 }
 
-/// \brief Metafunction to determine if type T has a member called getDecl.
+// Metafunction to determine if type T has a member called
+// getDecl.
+#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__clang__)
+// For old versions of MSVC, we use a weird nonstandard __if_exists
+// statement, since before MSVC2015, it was not standards-conformant
+// enough to compile the usual code below.
 template  struct has_getDecl {
-  struct Default { int getDecl; };
-  struct Derived : T, Default { };
-
-  template struct CheckT;
-
-  // If T::getDecl exists, an ambiguity arises and CheckT will
-  // not be instantiable. This makes f(...) the only available
-  // overload.
-  template
-  static char (&f(CheckT*))[1];
-  template static char (&f(...))[2];
-
-  static bool const value = sizeof(f(nullptr)) == 2;
+  __if_exists(T::getDecl) {
+enum { value = 1 };
+  }
+  __if_not_exists(T::getDecl) {
+enum { value = 0 };
+  }
 };
+#else
+// There is a default template inheriting from "false_type". Then, a
+// partial specialization inherits from "true_type". However, this
+// specialization will only exist when the call to getDecl() isn't an
+// error -- it vanishes by SFINAE when the member doesn't exist.
+template  struct type_sink_to_void { typedef void type; };
+template  struct has_getDecl : std::false_type {};
+template 
+struct has_getDecl<
+T, typename type_sink_to_void().getDecl())>::type>
+: std::true_type {};
+#endif
 
 /// \brief Matches overloaded operators with a specific name.
 ///


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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:5
@@ +4,2 @@
+.. meta::
+   :http-equiv=refresh: 0;URL=misc-new-delete-overloads.html

aaron.ballman wrote:
> alexfh wrote:
> > alexfh wrote:
> > > aaron.ballman wrote:
> > > > alexfh wrote:
> > > > > Since this is not a deprecated/obsolete file, it might be a good idea 
> > > > > to also add a textual redirection with native RST links for media not 
> > > > > supporting HTTP redirects (e.g. PDF or whatever else can be generated 
> > > > > from the RST files).
> > > > So basically use a regular link instead of the meta redirect?
> > > I'd use either a regular link, or both a link and the redirect.
> > One interesting aspect to consider is the bingability of check names, e.g. 
> > http://www.bing.com/search?q=google-build-namespaces or 
> > http://www.google.com/search?q=misc-new-delete-overloads (apparently, this 
> > one doesn't work well with bing).
> > 
> > I'm not sure redirects will play well with it, but we can try. Inclusion of 
> > the checks in the index seems like the must though, if we want the checks 
> > to be searchable.
> I think a link and the redirect make sense. Would a 5 second delay be a 
> reasonable amount of time before the auto redirect?
> 
> Also, the more I think on it, the more I agree that we want the checks in the 
> index file. I think it might be best to make the aliases visually distinct, 
> though. So perhaps something like:
> 
> cert-dcl54-cpp (alias to misc-new-delete-overloads)
> 
> And then have the link go directly to misc-new-delete-overloads instead of 
> making them click through or wait for the redirect?
Let's try with links to aliases and a delayed redirect and then see how it 
works.

> I think it might be best to make the aliases visually distinct, though. So 
> perhaps something like:
> 
> cert-dcl54-cpp (alias to misc-new-delete-overloads)

We need to teach add_new_check.py to retain (or automatically generate) these 
comments then.


http://reviews.llvm.org/D15796



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


Re: [clang-tools-extra] r256562 - [clang-tidy] Fix a use-after-free bug found by asan

2015-12-29 Thread Alexander Kornienko via cfe-commits
On Tue, Dec 29, 2015 at 5:22 PM, Benjamin Kramer 
wrote:

> On Tue, Dec 29, 2015 at 5:14 PM, Alexander Kornienko via cfe-commits
>  wrote:
> > Author: alexfh
> > Date: Tue Dec 29 10:14:38 2015
> > New Revision: 256562
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=256562&view=rev
> > Log:
> > [clang-tidy] Fix a use-after-free bug found by asan
> >
> > Modified:
> >
>  clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
> >
> > Modified:
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=256562&r1=256561&r2=256562&view=diff
> >
> ==
> > ---
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
> (original)
> > +++
> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
> Tue Dec 29 10:14:38 2015
> > @@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(con
> >  bool containsDiscardedTokens(
> >  const ast_matchers::MatchFinder::MatchResult &Result,
> >  CharSourceRange CharRange) {
> > -  StringRef ReplacementText =
> > +  std::string ReplacementText =
> >Lexer::getSourceText(CharRange, *Result.SourceManager,
> > -   Result.Context->getLangOpts()).str();
> > +   Result.Context->getLangOpts())
> > +  .str();
>
> Can you just drop the .str() and change the type back to StringRef?
>

That was what I asked the author of the original patch. However, Lexer
expects the buffer to end with a '\0', so the author did only a half of my
suggestion and I skipped the issue ;)

An alternative solution would be to create a lexer from the whole buffer,
but then the code would be much more complicated for no reason. Keep in
mind that we only do this when we're generating a warning anyway, so
copying a string is not going to be a bottleneck.


>
> - Ben
>
> >Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
> >  ReplacementText.data(), ReplacementText.data(),
> >  ReplacementText.data() + ReplacementText.size());
> >
> >
> > ___
> > 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


Re: [PATCH] D15805: [clang-tidy] Cleanup code in CERT module.

2015-12-29 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D15805#317657, @aaron.ballman wrote:

> Fine by me -- I went with CERT since it's an acronym, but we don't do this 
> for LLVM, so this change makes sense. Thanks!


AFAIU, LLVM is not an acronym anymore ;) (but still an upper-case spelling is 
the correct one).


Repository:
  rL LLVM

http://reviews.llvm.org/D15805



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


Re: [PATCH] D15805: [clang-tidy] Cleanup code in CERT module.

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Fine by me -- I went with CERT since it's an acronym, but we don't do this for 
LLVM, so this change makes sense. Thanks!

In http://reviews.llvm.org/D15805#317736, @alexfh wrote:

> In http://reviews.llvm.org/D15805#317657, @aaron.ballman wrote:
>
> > Fine by me -- I went with CERT since it's an acronym, but we don't do this 
> > for LLVM, so this change makes sense. Thanks!
>
>
> AFAIU, LLVM is not an acronym anymore ;) (but still an upper-case spelling is 
> the correct one).


Hah, good point. ;-) Regardless, I am fine with the namespace being "cert" in 
code so that it isn't confused with a macro.


Repository:
  rL LLVM

http://reviews.llvm.org/D15805



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


r256567 - [analyzer] Nullability: allow cast to _Nonnull to suppress warning about returning nil.

2015-12-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Dec 29 11:40:49 2015
New Revision: 256567

URL: http://llvm.org/viewvc/llvm-project?rev=256567&view=rev
Log:
[analyzer] Nullability: allow cast to _Nonnull to suppress warning about 
returning nil.

The nullability checker currently allows casts to suppress warnings when a nil
literal is passed as an argument to a parameter annotated as _Nonnull:

  foo((NSString * _Nonnull)nil); // no-warning

It does so by suppressing the diagnostic when the *type* of the argument 
expression
is _Nonnull -- even when the symbolic value returned is known to be nil.

This commit updates the nullability checker to similarly honor such casts in 
the analogous
scenario when nil is returned from a function with a _Nonnull return type:

  return (NSString * _Nonnull)nil; // no-warning

This commit also normalizes variable naming between the parameter and return 
cases and
adds several tests demonstrating the limitations of this suppression mechanism 
(such as
when nil is cast to _Nonnull and then stored into a local variable without a 
nullability
qualifier). These tests are marked with FIXMEs.

rdar://problem/23176782

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=256567&r1=256566&r2=256567&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Tue Dec 29 
11:40:49 2015
@@ -492,12 +492,21 @@ void NullabilityChecker::checkPreStmt(co
 
   NullConstraint Nullness = getNullConstraint(*RetSVal, State);
 
-  Nullability StaticNullability =
+  Nullability RequiredNullability =
   getNullabilityAnnotation(FuncType->getReturnType());
 
+  // If the returned value is null but the type of the expression
+  // generating it is nonnull then we will suppress the diagnostic.
+  // This enables explicit suppression when returning a nil literal in a
+  // function with a _Nonnull return type:
+  //return (NSString * _Nonnull)0;
+  Nullability RetExprTypeLevelNullability =
+getNullabilityAnnotation(RetExpr->getType());
+
   if (Filter.CheckNullReturnedFromNonnull &&
   Nullness == NullConstraint::IsNull &&
-  StaticNullability == Nullability::Nonnull) {
+  RetExprTypeLevelNullability != Nullability::Nonnull &&
+  RequiredNullability == Nullability::Nonnull) {
 static CheckerProgramPointTag Tag(this, "NullReturnedFromNonnull");
 ExplodedNode *N = C.generateErrorNode(State, &Tag);
 if (!N)
@@ -518,7 +527,7 @@ void NullabilityChecker::checkPreStmt(co
 if (Filter.CheckNullableReturnedFromNonnull &&
 Nullness != NullConstraint::IsNotNull &&
 TrackedNullabValue == Nullability::Nullable &&
-StaticNullability == Nullability::Nonnull) {
+RequiredNullability == Nullability::Nonnull) {
   static CheckerProgramPointTag Tag(this, "NullableReturnedFromNonnull");
   ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
   reportBugIfPreconditionHolds(ErrorKind::NullableReturnedToNonnull, N,
@@ -526,9 +535,10 @@ void NullabilityChecker::checkPreStmt(co
 }
 return;
   }
-  if (StaticNullability == Nullability::Nullable) {
+  if (RequiredNullability == Nullability::Nullable) {
 State = State->set(Region,
-   NullabilityState(StaticNullability, S));
+   NullabilityState(RequiredNullability,
+S));
 C.addTransition(State);
   }
 }
@@ -564,13 +574,14 @@ void NullabilityChecker::checkPreCall(co
 
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
-Nullability ParamNullability = getNullabilityAnnotation(Param->getType());
-Nullability ArgStaticNullability =
+Nullability RequiredNullability =
+getNullabilityAnnotation(Param->getType());
+Nullability ArgExprTypeLevelNullability =
 getNullabilityAnnotation(ArgExpr->getType());
 
 if (Filter.CheckNullPassedToNonnull && Nullness == NullConstraint::IsNull 
&&
-ArgStaticNullability != Nullability::Nonnull &&
-ParamNullability == Nullability::Nonnull) {
+ArgExprTypeLevelNullability != Nullability::Nonnull &&
+RequiredNullability == Nullability::Nonnull) {
   ExplodedNode *N = C.generateErrorNode(State);
   if (!N)
 return;
@@ -592,7 +603,7 @@ void NullabilityChecker::checkPreCall(co
 continue;
 
   if (Filter.CheckNullablePassedToNonnull &&
-  ParamNullability == Nullability::Nonnull) {
+  RequiredNullability == Nullability::Nonnull) {
 ExplodedNode *N = C.addTransition(State);
 reportBugIfPr

Re: [PATCH] D15791: Disable generating movt on FreeBSD

2015-12-29 Thread Andrew Turner via cfe-commits
andrew added a comment.

Can someone commit with the FIXME comment? I'm unable to do it myself.


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


Re: [PATCH] D15623: Add UnnecessaryCopyInitialization check to new "performance" module in ClangTidy

2015-12-29 Thread Felix Berger via cfe-commits
flx updated this revision to Diff 43743.
flx marked 2 inline comments as done.

http://reviews.llvm.org/D15623

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -0,0 +1,152 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+
+struct ExpensiveToCopyType {
+  ExpensiveToCopyType() {}
+  virtual ~ExpensiveToCopyType() {}
+  const ExpensiveToCopyType &reference() const { return *this; }
+};
+
+struct TrivialToCopyType {
+  const TrivialToCopyType &reference() const { return *this; }
+};
+
+const ExpensiveToCopyType &ExpensiveTypeReference() {
+  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
+  return *Type;
+}
+
+const TrivialToCopyType &TrivialTypeReference() {
+  static const TrivialToCopyType *Type = new TrivialToCopyType();
+  return *Type;
+}
+
+void PositiveFunctionCall() {
+  const auto AutoAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
+  const auto AutoCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
+  const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
+  const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+}
+
+void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
+  const auto AutoAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  const auto AutoCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  const ExpensiveToCopyType VarAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+}
+
+void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
+  const auto AutoAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  const auto AutoCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  const ExpensiveToCopyType VarAssigned = Obj.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+}
+
+void PositiveMethodCallConstPointerParam(const ExpensiveToCopyType *const Obj) {
+  const auto AutoAssigned = Obj->reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoAssigned = Obj->reference();
+  const auto AutoCopyConstructed(Obj->reference());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(Obj->reference());
+  const ExpensiveToCopyType VarAssigned = Obj->reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
+  // CHECK-FIXES: const ExpensiveToCopyTyp

Re: [PATCH] D15321: [OpenMP 4.0]Parsing and Sema support for 'omp declare target' directive (accelerator support)

2015-12-29 Thread Michael Wong via cfe-commits
fraggamuffin marked 15 inline comments as done.
fraggamuffin added a comment.

Thanks for the pre-xmas review.



Comment at: include/clang/AST/DeclOpenMP.h:98
@@ +97,3 @@
+///
+class OMPDeclareTargetDecl : public Decl, public DeclContext {
+   friend class ASTDeclReader;

ABataev wrote:
> I'm not sure that we need to add this kind of declaration. Most probably it 
> is enough just to have an attribute
I added attributes in a few places according to what was done with 
threadprivate but I am not sure it is enough. 


Comment at: lib/Parse/ParseOpenMP.cpp:209
@@ -142,2 +208,3 @@
   case OMPD_taskloop_simd:
+  default:
 Diag(Tok, diag::err_omp_unexpected_directive)

ABataev wrote:
> fraggamuffin wrote:
> > ABataev wrote:
> > > Do not add default:, coding standard recommends to not use it
> > This is needed to generate these error messages in 
> > declare_target_messages.cpp
> > error: 'error' diagnostics expected but not seen:
> >   File 
> > C:\llvm151206\llvm\tools\clang\test\OpenMP\declare_target_messages.cpp Li
> > ne 3: unexpected OpenMP directive '#pragma omp end declare target'
> >   File 
> > C:\llvm151206\llvm\tools\clang\test\OpenMP\declare_target_messages.cpp Li
> > ne 63: unexpected OpenMP directive '#pragma omp end declare target'
> >   File 
> > C:\llvm151206\llvm\tools\clang\test\OpenMP\declare_target_messages.cpp Li
> > ne 72: unexpected OpenMP directive '#pragma omp end declare target'
> > 3 errors generated.
> Still 'default:' is a bad solution. You must explicitly take all possible 
> cases for the enumeric type
I agree and see your point. Thanks.  I fixed it by adding the search for end 
declare target.


Comment at: lib/Parse/ParseOpenMP.cpp:387-392
@@ -318,2 +386,8 @@
 break;
+  default:
+ Diag(Tok, diag::err_omp_unexpected_directive)
+ << getOpenMPDirectiveName(DKind);
+ while (!SkipUntil(tok::annot_pragma_openmp_end))
+ ;
+ break;
   }

ABataev wrote:
> fraggamuffin wrote:
> > ABataev wrote:
> > > Do not add it
> > This is needed to prevent infinite loop when there is an unexpected end of 
> > the pragma omp target.
> As I said before 'default:' is a bad solution. Add explicit cases for all 
> possible values
I agree and see your point. Thanks.  I fixed it .


Comment at: lib/Sema/SemaOpenMP.cpp:1139-1140
@@ -1105,3 +1138,4 @@
   QualType ExprType = VD->getType().getNonReferenceType();
-  ExprResult DE = buildDeclRefExpr(*this, VD, ExprType, Id.getLoc());
+  //ExprResult DE = buildDeclRefExpr(*this, VD, ExprType, Id.getLoc());
+  ExprResult DE = BuildDeclRefExpr(VD, ExprType, VK_LValue, Id.getLoc());
   return DE;

ABataev wrote:
> fraggamuffin wrote:
> > ABataev wrote:
> > > I don't understand why you changed this.
> > The buildDeclRefExpr interface does not enable us to generate these 
> > messages.
> > Someone changed it to buildDeclRefExpr(...) which has a different interface
> > In the github repository it also uses 
> > ExprResult DE = BuildDeclRefExpr(VD, ExprType, VK_LValue, Id.getLoc());
> > 
> > With the buildDeclRefExpr interface, it misses generation of these messages
> > error: 'warning' diagnostics expected but not seen:
> >   File 
> > C:\llvm151206\llvm\tools\clang\test\OpenMP\declare_target_messages.cpp Li
> > ne 5: declaration is not declared in any declare target region
> > error: 'note' diagnostics expected but not seen:
> >   File 
> > C:\llvm151206\llvm\tools\clang\test\OpenMP\declare_target_messages.cpp Li
> > ne 21: used here
> > 2 errors generated.
> > 
> Github is not a reference version, it has many very bad and not working 
> solutions. You don't need take everything from there, some solutions are just 
> not compatible with trunk
OK, I looked at the uses of build.. and Build.. and see that build... is only 
used within SemaOpenMP.cpp, so I changed it back, and added my check inside 
build... for when it is in a target region. Thanks.


http://reviews.llvm.org/D15321



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


r256570 - [TrailingObjects] Convert AST classes that had a ASTTemplateKWAndArgsInfo.

2015-12-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Dec 29 12:15:14 2015
New Revision: 256570

URL: http://llvm.org/viewvc/llvm-project?rev=256570&view=rev
Log:
[TrailingObjects] Convert AST classes that had a ASTTemplateKWAndArgsInfo.

So, also:

- Moved the TemplateArgumentLoc array out of the
  ASTTemplateKWAndArgsInfo class (making it a simple fixed-size object),
  to avoid needing to have a variable-length object as part of a
  variable-length object. Now the objects that have a
  ASTTemplateKWAndArgsInfo also have some TemplateArgumentLoc objects
  appended directly.

- Removed some internal-use accessors which became simply a wrapper on
  getTrailingObjects.

- Moved MemberNameQualifier out of the MemberExpr class, renamed it
  MemberExprNameQualifier, because the template can't
  refer to a class nested within the class it's defining.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/TemplateBase.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/TemplateBase.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=256570&r1=256569&r2=256570&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Dec 29 12:15:14 2015
@@ -919,7 +919,11 @@ public:
 ///   DeclRefExprBits.RefersToEnclosingVariableOrCapture
 ///   Specifies when this declaration reference expression (validly)
 ///   refers to an enclosed local or a captured variable.
-class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) DeclRefExpr : public Expr {
+class DeclRefExpr final
+: public Expr,
+  private llvm::TrailingObjects {
   /// \brief The declaration that we are referencing.
   ValueDecl *D;
 
@@ -930,36 +934,22 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/
   /// embedded in D.
   DeclarationNameLoc DNLoc;
 
-  /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
-  NestedNameSpecifierLoc &getInternalQualifierLoc() {
-assert(hasQualifier());
-return *reinterpret_cast(this + 1);
+  size_t numTrailingObjects(OverloadToken) const {
+return hasQualifier() ? 1 : 0;
   }
 
-  /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
-  const NestedNameSpecifierLoc &getInternalQualifierLoc() const {
-return const_cast(this)->getInternalQualifierLoc();
+  size_t numTrailingObjects(OverloadToken) const {
+return hasFoundDecl() ? 1 : 0;
+  }
+
+  size_t numTrailingObjects(OverloadToken) const {
+return hasTemplateKWAndArgsInfo() ? 1 : 0;
   }
 
   /// \brief Test whether there is a distinct FoundDecl attached to the end of
   /// this DRE.
   bool hasFoundDecl() const { return DeclRefExprBits.HasFoundDecl; }
 
-  /// \brief Helper to retrieve the optional NamedDecl through which this
-  /// reference occurred.
-  NamedDecl *&getInternalFoundDecl() {
-assert(hasFoundDecl());
-if (hasQualifier())
-  return *reinterpret_cast(&getInternalQualifierLoc() + 1);
-return *reinterpret_cast(this + 1);
-  }
-
-  /// \brief Helper to retrieve the optional NamedDecl through which this
-  /// reference occurred.
-  NamedDecl *getInternalFoundDecl() const {
-return const_cast(this)->getInternalFoundDecl();
-  }
-
   DeclRefExpr(const ASTContext &Ctx,
   NestedNameSpecifierLoc QualifierLoc,
   SourceLocation TemplateKWLoc,
@@ -1032,21 +1022,17 @@ public:
   bool hasQualifier() const { return DeclRefExprBits.HasQualifier; }
 
   /// \brief If the name was qualified, retrieves the nested-name-specifier
-  /// that precedes the name. Otherwise, returns NULL.
-  NestedNameSpecifier *getQualifier() const {
-if (!hasQualifier())
-  return nullptr;
-
-return getInternalQualifierLoc().getNestedNameSpecifier();
-  }
-
-  /// \brief If the name was qualified, retrieves the nested-name-specifier
   /// that precedes the name, with source-location information.
   NestedNameSpecifierLoc getQualifierLoc() const {
 if (!hasQualifier())
   return NestedNameSpecifierLoc();
+return *getTrailingObjects();
+  }
 
-return getInternalQualifierLoc();
+  /// \brief If the name was qualified, retrieves the nested-name-specifier
+  /// that precedes the name. Otherwise, returns NULL.
+  NestedNameSpecifier *getQualifier() const {
+return getQualifierLoc().getNestedNameSpecifier();
   }
 
   /// \brief Get the NamedDecl through which this reference occurred.
@@ -1054,64 +1040,40 @@ public:
   /// This Decl may be different from the ValueDecl actually referred to in the
   /// presence of using declarations, etc. It always returns non-NULL, and may
   /// simple return the ValueDecl when appropriate.
+
   NamedDecl *getFoundDecl() {
-return hasFoundDecl() ? getInternalFoundDecl()

Re: [PATCH] D15321: [OpenMP 4.0]Parsing and Sema support for 'omp declare target' directive (accelerator support)

2015-12-29 Thread Michael Wong via cfe-commits
fraggamuffin updated this revision to Diff 43746.
fraggamuffin marked 3 inline comments as done.
fraggamuffin added a comment.

Fixed Comments from Dec 17.


http://reviews.llvm.org/D15321

Files:
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclOpenMP.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclOpenMP.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTCommon.h
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/declare_target_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5228,6 +5228,7 @@
   case Decl::ClassScopeFunctionSpecialization:
   case Decl::Import:
   case Decl::OMPThreadPrivate:
+  case Decl::OMPDeclareTarget:
   case Decl::ObjCTypeParam:
   case Decl::BuiltinTemplate:
 return C;
Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s
+
+#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
+
+int a, b; // expected-warning 2 {{declaration is not declared in any declare target region}}
+__thread int t; // expected-error {{threadprivate variables cannot be used in target constructs}}
+#pragma omp declare target private(a) // expected-warning {{extra tokens at the end of '#pragma omp declare target' are ignored}}
+void f();
+#pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}}
+void c(); // expected-warning {{declaration is not declared in any declare target region}}
+
+extern int b;
+
+struct NonT {
+  int a;
+};
+
+typedef int sint;
+
+#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}}
+#pragma omp threadprivate(a) // expected-error {{threadprivate variables cannot be used in target constructs}} expected-note {{used here}}
+extern int b;
+int g;
+
+struct T { // expected-note {{mappable type cannot be polymorphic}}
+  int a;
+  virtual int method();
+};
+
+class VC { // expected-note {{mappable type cannot be polymorphic}}
+  T member;
+  NonT member1;
+  public:
+virtual int method() { T a; return 0; } // expected-error {{type 'T' is not mappable to target}}
+};
+
+struct C {
+  NonT a;
+  sint b;
+  int method();
+  int method1();
+};
+
+int C::method1() {
+  return 0;
+}
+
+void foo() {
+  a = 0; // expected-note {{used here}}
+  b = 0; // expected-note {{used here}}
+  t = 1; // expected-note {{used here}}
+  C object;
+  VC object1; // expected-error {{type 'VC' is not mappable to target}}
+  g = object.method();
+  g += object.method1();
+  g += object1.method();
+  f();
+  c(); // expected-note {{used here}}
+}
+#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}}
+void foo1() {}
+#pragma omp end declare target
+#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
+
+int C::method() {
+  return 0;
+}
+
+struct S {
+#pragma omp declare target // expected-error {{directive must be at file or namespace scope}}
+  int v;
+#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
+};
+
+int main (int argc, char **argv) {
+#pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}}
+  int v;
+#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
+  foo();
+  return (0);
+}
+
+#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragm

Re: [PATCH] D15797: [clang-tidy] Fix readability-braces-around-statements assert failure

2015-12-29 Thread Matt Stancliff via cfe-commits
mattsta added a comment.

It's difficult to track down *why* the invalid locations are happening because 
by the time we get to an invalid location, all source location information is 
lost.  The best I've been able to come up with is fixing the early return 
conditions (which were previously impossible to reach due to asserts catching 
the invalid conditions first).

It's easy to have these happen on any large codebase (e.g. try to recursively 
clang-tidy the erlang source tree with readability-braces-around-statements).


Repository:
  rL LLVM

http://reviews.llvm.org/D15797



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


Re: [PATCH] D15797: [clang-tidy] Fix readability-braces-around-statements assert failure

2015-12-29 Thread Matt Stancliff via cfe-commits
mattsta updated this revision to Diff 43748.
mattsta added a comment.

Updated to include fix for:

  Assertion failed: (InitialLoc.isValid()), function checkStmt, file 
../llvm/tools/clang/tools/extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp,
 line 226.


Repository:
  rL LLVM

http://reviews.llvm.org/D15797

Files:
  BracesAroundStatementsCheck.cpp

Index: BracesAroundStatementsCheck.cpp
===
--- BracesAroundStatementsCheck.cpp
+++ BracesAroundStatementsCheck.cpp
@@ -143,14 +143,14 @@
   } else if (auto S = Result.Nodes.getNodeAs("do")) {
 checkStmt(Result, S->getBody(), S->getDoLoc(), S->getWhileLoc());
   } else if (auto S = Result.Nodes.getNodeAs("while")) {
-SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-if (StartLoc.isInvalid())
+if (S->getCond()->getLocStart().isInvalid())
   return;
+SourceLocation StartLoc = findRParenLoc(S, SM, Context);
 checkStmt(Result, S->getBody(), StartLoc);
   } else if (auto S = Result.Nodes.getNodeAs("if")) {
-SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-if (StartLoc.isInvalid())
+if (S->getCond()->getLocStart().isInvalid())
   return;
+SourceLocation StartLoc = findRParenLoc(S, SM, Context);
 if (ForceBracesStmts.erase(S))
   ForceBracesStmts.insert(S->getThen());
 bool BracedIf = checkStmt(Result, S->getThen(), StartLoc, S->getElseLoc());
@@ -219,7 +219,7 @@
   CharSourceRange FileRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(S->getSourceRange()), SM,
   Context->getLangOpts());
-  if (FileRange.isInvalid())
+  if (FileRange.isInvalid() || InitialLoc.isInvalid())
 return false;
 
   // InitialLoc points at the last token before opening brace to be inserted.


Index: BracesAroundStatementsCheck.cpp
===
--- BracesAroundStatementsCheck.cpp
+++ BracesAroundStatementsCheck.cpp
@@ -143,14 +143,14 @@
   } else if (auto S = Result.Nodes.getNodeAs("do")) {
 checkStmt(Result, S->getBody(), S->getDoLoc(), S->getWhileLoc());
   } else if (auto S = Result.Nodes.getNodeAs("while")) {
-SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-if (StartLoc.isInvalid())
+if (S->getCond()->getLocStart().isInvalid())
   return;
+SourceLocation StartLoc = findRParenLoc(S, SM, Context);
 checkStmt(Result, S->getBody(), StartLoc);
   } else if (auto S = Result.Nodes.getNodeAs("if")) {
-SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-if (StartLoc.isInvalid())
+if (S->getCond()->getLocStart().isInvalid())
   return;
+SourceLocation StartLoc = findRParenLoc(S, SM, Context);
 if (ForceBracesStmts.erase(S))
   ForceBracesStmts.insert(S->getThen());
 bool BracedIf = checkStmt(Result, S->getThen(), StartLoc, S->getElseLoc());
@@ -219,7 +219,7 @@
   CharSourceRange FileRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(S->getSourceRange()), SM,
   Context->getLangOpts());
-  if (FileRange.isInvalid())
+  if (FileRange.isInvalid() || InitialLoc.isInvalid())
 return false;
 
   // InitialLoc points at the last token before opening brace to be inserted.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread John McCall via cfe-commits
rjmccall added a comment.

This looks great, thanks.  A few minor comment tweaks and this will be ready to 
commit.



Comment at: include/clang/AST/DeclBase.h:562
@@ -561,1 +561,3 @@
 
+  /// \brief Return true if this declaration is a definition of alias or ifunc.
+  bool hasDefiningAttr() const;

"Return true if this declaration has an attribute which acts as a definition of 
the entity, such as 'alias' or 'ifunc'."


Comment at: include/clang/AST/DeclBase.h:565
@@ +564,3 @@
+
+  /// \brief Returns AliasAttr or IFuncAttr if any or nullptr.
+  Attr* getDefiningAttr() const;

"Return this declaration's defining attribute if it has one."

Also, please put the * next to the method name rather than the type.


Comment at: include/clang/Basic/AttrDocs.td:1868
@@ +1867,3 @@
+
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
function pointer.
+

Okay, this should just say "...and return a pointer", since that's all we're 
enforcing.


Comment at: lib/Sema/SemaDecl.cpp:2316
@@ -2315,3 +2315,3 @@
 ? diag::err_alias_after_tentative
 : diag::err_redefinition;
 S.Diag(VD->getLocation(), Diag) << VD->getDeclName();

Oh, of course, makes sense.


http://reviews.llvm.org/D15524



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


r256575 - Teach typo correction to properly handle mapping declarations to their

2015-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 29 13:43:10 2015
New Revision: 256575

URL: http://llvm.org/viewvc/llvm-project?rev=256575&view=rev
Log:
Teach typo correction to properly handle mapping declarations to their
underlying decls. Preserve the found declaration throughout, and only map to
the underlying declaration when we want to check whether it's the right kind.
This allows us to provide the right source location for the found declaration,
and prepares for the possibility of underlying decls with a different name
from the found decl.

Modified:
cfe/trunk/include/clang/Sema/TypoCorrection.h
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/include/clang/Sema/TypoCorrection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TypoCorrection.h?rev=256575&r1=256574&r2=256575&view=diff
==
--- cfe/trunk/include/clang/Sema/TypoCorrection.h (original)
+++ cfe/trunk/include/clang/Sema/TypoCorrection.h Tue Dec 29 13:43:10 2015
@@ -72,15 +72,15 @@ public:
 
   /// \brief Gets the DeclarationName of the typo correction
   DeclarationName getCorrection() const { return CorrectionName; }
-  IdentifierInfo* getCorrectionAsIdentifierInfo() const {
+  IdentifierInfo *getCorrectionAsIdentifierInfo() const {
 return CorrectionName.getAsIdentifierInfo();
   }
 
   /// \brief Gets the NestedNameSpecifier needed to use the typo correction
-  NestedNameSpecifier* getCorrectionSpecifier() const {
+  NestedNameSpecifier *getCorrectionSpecifier() const {
 return CorrectionNameSpec;
   }
-  void setCorrectionSpecifier(NestedNameSpecifier* NNS) {
+  void setCorrectionSpecifier(NestedNameSpecifier *NNS) {
 CorrectionNameSpec = NNS;
 ForceSpecifierReplacement = (NNS != nullptr);
   }
@@ -129,9 +129,16 @@ public:
 return Normalized ? NormalizeEditDistance(ED) : ED;
   }
 
+  /// \brief Get the correction declaration found by name lookup (before we
+  /// looked through using shadow declarations and the like).
+  NamedDecl *getFoundDecl() const {
+return hasCorrectionDecl() ? *(CorrectionDecls.begin()) : nullptr;
+  }
+
   /// \brief Gets the pointer to the declaration of the typo correction
   NamedDecl *getCorrectionDecl() const {
-return hasCorrectionDecl() ? *(CorrectionDecls.begin()) : nullptr;
+auto *D = getFoundDecl();
+return D ? D->getUnderlyingDecl() : nullptr;
   }
   template 
   DeclClass *getCorrectionDeclAs() const {
@@ -180,8 +187,7 @@ public:
   // Check if this TypoCorrection is a keyword by checking if the first
   // item in CorrectionDecls is NULL.
   bool isKeyword() const {
-return !CorrectionDecls.empty() &&
-CorrectionDecls.front() == nullptr;
+return !CorrectionDecls.empty() && CorrectionDecls.front() == nullptr;
   }
 
   // Check if this TypoCorrection is the given keyword.

Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=256575&r1=256574&r2=256575&view=diff
==
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Tue Dec 29 13:43:10 2015
@@ -607,7 +607,7 @@ bool Sema::BuildCXXNestedNameSpecifier(S
 diagnoseTypo(Corrected, PDiag(diag::err_undeclared_var_use_suggest)
   << Name);
 
-  if (NamedDecl *ND = Corrected.getCorrectionDecl())
+  if (NamedDecl *ND = Corrected.getFoundDecl())
 Found.addDecl(ND);
   Found.setLookupName(Corrected.getCorrection());
 } else {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256575&r1=256574&r2=256575&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 29 13:43:10 2015
@@ -813,9 +813,8 @@ Corrected:
 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
 unsigned QualifiedDiag = diag::err_no_member_suggest;
 
-NamedDecl *FirstDecl = Corrected.getCorrectionDecl();
-NamedDecl *UnderlyingFirstDecl
-  = FirstDecl? FirstDecl->getUnderlyingDecl() : nullptr;
+NamedDecl *FirstDecl = Corrected.getFoundDecl();
+NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
 if (getLangOpts().CPlusPlus && NextToken.is(tok::less) &&
 UnderlyingFirstDecl && isa(UnderlyingFirstDecl)) {
   UnqualifiedDiag = diag::err_no_template_suggest;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org

Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/AST/DeclBase.h:563
@@ +562,3 @@
+  /// \brief Return true if this declaration is a definition of alias or ifunc.
+  bool hasDefiningAttr() const;
+

I think this function and getDefiningAttr() can be defined in the header 
instead of split into the source file. The implementations are short enough 
that inlining may be nice to allow.


Comment at: include/clang/AST/DeclBase.h:565
@@ +564,3 @@
+
+  /// \brief Returns AliasAttr or IFuncAttr if any or nullptr.
+  Attr* getDefiningAttr() const;

rjmccall wrote:
> "Return this declaration's defining attribute if it has one."
> 
> Also, please put the * next to the method name rather than the type.
Also, since this is a const method, I'd prefer if it returned a `const Attr *` 
if possible.


Comment at: lib/AST/DeclBase.cpp:369
@@ +368,3 @@
+
+Attr* Decl::getDefiningAttr() const {
+  if (AliasAttr *AA = getAttr())

Attr* -> Attr *


Comment at: lib/Sema/SemaDeclAttr.cpp:1538
@@ +1537,3 @@
+  // Aliases should be on declarations, not definitions.
+  if (const auto *FD = dyn_cast(D)) {
+if (FD->isThisDeclarationADefinition()) {

Can use cast<> instead of dyn_cast<> and remove the if.


Comment at: lib/Sema/SemaDeclAttr.cpp:1543
@@ +1542,3 @@
+}
+if (S.Context.getTargetInfo().getTriple().getObjectFormat() !=
+llvm::Triple::ELF) {

I think that this should be codified in Attr.td as a target-specific attribute; 
though that may require a bit of work for the attribute emitter to handle. I 
don't think this needs to be done in this patch, but it should at least have a 
FIXME or be handled in a follow-up patch.


Comment at: lib/Sema/SemaDeclAttr.cpp:1549
@@ +1548,3 @@
+  } else
+llvm_unreachable("ifunc must be used for function declaration");
+

Can remove the else clause entirely; common attribute handling already takes 
care of this and by switching to use cast<> instead of dyn_cast<> you already 
get an assert if the type is incorrect.


http://reviews.llvm.org/D15524



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


r256576 - fix typos; NFC

2015-12-29 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue Dec 29 14:09:37 2015
New Revision: 256576

URL: http://llvm.org/viewvc/llvm-project?rev=256576&view=rev
Log:
fix typos; NFC

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256576&r1=256575&r2=256576&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 29 14:09:37 2015
@@ -795,7 +795,7 @@ Corrected:
 }
 
 // In C, we first see whether there is a tag type by the same name, in 
-// which case it's likely that the user just forget to write "enum", 
+// which case it's likely that the user just forgot to write "enum", 
 // "struct", or "union".
 if (!getLangOpts().CPlusPlus && !SecondTry &&
 isTagTypeWithMissingTag(*this, Result, S, SS, Name, NameLoc)) {

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256576&r1=256575&r2=256576&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 29 14:09:37 2015
@@ -4772,7 +4772,7 @@ static bool checkArgsForPlaceholders(Sem
 }
 
 /// If a builtin function has a pointer argument with no explicit address
-/// space, than it should be able to accept a pointer to any address
+/// space, then it should be able to accept a pointer to any address
 /// space as input.  In order to do this, we need to replace the
 /// standard builtin declaration with one that uses the same address space
 /// as the call.
@@ -4953,7 +4953,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn,
 
 FunctionDecl *FDecl = dyn_cast(NDecl);
 if (FDecl && FDecl->getBuiltinID()) {
-  // Rewrite the function decl for this builtin by replacing paramaters
+  // Rewrite the function decl for this builtin by replacing parameters
   // with no explicit address space with the address space of the arguments
   // in ArgExprs.
   if ((FDecl = rewriteBuiltinFunctionDecl(this, Context, FDecl, 
ArgExprs))) {


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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/AST/DeclBase.h:563
@@ +562,3 @@
+  /// \brief Return true if this declaration is a definition of alias or ifunc.
+  bool hasDefiningAttr() const;
+

aaron.ballman wrote:
> I think this function and getDefiningAttr() can be defined in the header 
> instead of split into the source file. The implementations are short enough 
> that inlining may be nice to allow.
getDefiningAttr can't be defined in the header without including Attr.h.  We 
could define hasDefiningAttr in terms of getDefiningAttr, but it wouldn't allow 
much interesting optimization.


http://reviews.llvm.org/D15524



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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/AST/DeclBase.h:563
@@ +562,3 @@
+  /// \brief Return true if this declaration is a definition of alias or ifunc.
+  bool hasDefiningAttr() const;
+

rjmccall wrote:
> aaron.ballman wrote:
> > I think this function and getDefiningAttr() can be defined in the header 
> > instead of split into the source file. The implementations are short enough 
> > that inlining may be nice to allow.
> getDefiningAttr can't be defined in the header without including Attr.h.  We 
> could define hasDefiningAttr in terms of getDefiningAttr, but it wouldn't 
> allow much interesting optimization.
Good point; definitely not worth it.


http://reviews.llvm.org/D15524



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


[PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-29 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: mclow.lists, jroelofs, danalbert, EricWF.
bcraig added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

This patch makes it easier to support running the lit tests for new and
unusual platforms.  It will break existing users that set LIBCXX_TARGET_INFO
to anything other than the default.  I think this is fine, because the old
LIBCXX_TARGET_INFO wasn't terribly useful.

The old way of supporting the different test platforms was to have conditional
code scattered throughout config.py.  New platforms would need to add
conditionals there.  Alternatively, the new platform could set 
no_default_flags to true, and reconstitue almost the entire compile and link
line, including things that don't vary across platforms.

The new way of supporting new platforms is to create a new target info class,
and have make_target_info return an instance of it.  For platforms supported
in-tree, that will be done by modifying make_target_info.  For out-of-tree
platforms, users can set LIBCXX_TARGET_INFO at cmake configure time.

The target info sub-classes can provide fine-grained information back to
config.py.  The hooks that will most commonly be provided will be
add_cxx_compile_flags and add_cxx_link_flags.  These hooks can provide the
platform specific flags, while letting config.py handle all the invariant
flags.

Target info hooks were added for each area that the existing config.py had
platform specific behavior.  config.py is now mostly free of platform specific
conditionals.

This patch was tested on Linux x86_64.  I both targeted Linux x86_64, and an
out-of-tree platform with a custom target_info.  In both cases I was able to
run libcxx and libcxxabi tests.  I do not have access to FreeBSD, Darwin, or
Windows machines that are set up for lit testing.


http://reviews.llvm.org/D15813

Files:
  test/libcxx/test/config.py
  test/libcxx/test/target_info.py

Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -1,55 +1,160 @@
+import importlib
 import locale
+import os
 import platform
 import sys
 
-class TargetInfo(object):
-def platform(self):
-raise NotImplementedError
+class DefaultTargetInfo(object):
+def __init__(self, full_config):
+self.full_config = full_config
+def platform(self):return sys.platform.lower().strip()
 
-def system(self):
-raise NotImplementedError
+def add_locale_features(self, features):
+self.full_config.lit_config.warning(
+"No locales entry for target_system: %s" % self.platform())
 
-def platform_ver(self):
-raise NotImplementedError
+def add_cxx_compile_flags(self, flags): pass
+def add_cxx_link_flags(self, flags): pass
+def configure_env(self, env): pass
+def allow_cxxabi_link(self): return True
+def add_sanitizer_features(self, sanitizer_type, features): pass
+def use_lit_shell_default(self): return False
 
-def platform_name(self):
-raise NotImplementedError
+def add_common_locales(features):
+locales = [
+'en_US.UTF-8',
+'cs_CZ.ISO8859-2',
+'fr_FR.UTF-8',
+'fr_CA.ISO8859-1',
+'ru_RU.UTF-8',
+'zh_CN.UTF-8',
+]
+for loc in locales:
+features.add('locale.{0}'.format(loc))
 
-def supports_locale(self, loc):
-raise NotImplementedError
+class DarwinLocalTI(DefaultTargetInfo):
+def __init__(self, full_config):
+super(DarwinLocalTI, self).__init__(full_config)
+def add_locale_features(self, features):
+add_common_locales(features)
+def add_cxx_compile_flags(self, flags):
+try:
+out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+res = 0
+except OSError:
+res = -1
+if res == 0 and out:
+sdk_path = out
+self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path)
+flags += ["-isysroot", sdk_path]
+def add_cxx_link_flags(self, flags):
+flags += ['-lSystem']
+def configure_env(self, env):
+library_paths = []
+# Configure the library path for libc++
+libcxx_library = self.full_config.get_lit_conf('libcxx_library')
+if self.full_config.use_system_cxx_lib:
+pass
+elif libcxx_library:
+library_paths += [os.path.dirname(libcxx_library)]
+elif self.full_config.cxx_library_root:
+library_paths += [self.full_config.cxx_library_root]
+# Configure the abi library path
+if self.full_config.abi_library_root:
+library_paths += [self.full_config.abi_library_root]
+if library_paths:
+env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths)
+def allow_cxxabi_link(self):
+# Don't link libc++abi explicitly on OS X because the symbols
+#

[PATCH] D15814: Implicit conversion from float->bool

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rtrieu, dblaikie.
aaron.ballman added a subscriber: cfe-commits.

When performing an implicit from float to bool, the floating point value must 
be *exactly* zero in order for the conversion to result in 0. This does not 
involve a conversion through an integer value, and so truncation of the value 
is not performed. This patch addresses this by using the floating-point value 
when determining whether to print "true" or "false" in the diagnostic. The 
behavior of the codegen has always been correct, so this only modifies the 
wording of the diagnostic to be accurate.

This patch address PR25876.

http://reviews.llvm.org/D15814

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- test/SemaCXX/warn-literal-conversion.cpp
+++ test/SemaCXX/warn-literal-conversion.cpp
@@ -38,3 +38,14 @@
   int y = (24*60*60) * 0.25;
   int pennies = 123.45 * 100;
 }
+
+// Similarly, test floating point conversion to bool. Only float values of zero
+// are converted to false; everything else is converted to true.
+void test1() {
+  bool b1 = 0.99f; // expected-warning {{implicit conversion from 'float' to 
'bool' changes value from 0.99 to true}}
+  bool b2 = 0.99; // expected-warning {{implicit conversion from 'double' to 
'bool' changes value from 0.99 to true}}
+  // These do not warn because they can be directly converted to integral
+  // values.
+  bool b3 = 0.0f;
+  bool b4 = 0.0;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6983,7 +6983,7 @@
 
   SmallString<16> PrettyTargetValue;
   if (T->isSpecificBuiltinType(BuiltinType::Bool))
-PrettyTargetValue = IntegerValue == 0 ? "false" : "true";
+PrettyTargetValue = Value.isZero() ? "false" : "true";
   else
 IntegerValue.toString(PrettyTargetValue);
 


Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- test/SemaCXX/warn-literal-conversion.cpp
+++ test/SemaCXX/warn-literal-conversion.cpp
@@ -38,3 +38,14 @@
   int y = (24*60*60) * 0.25;
   int pennies = 123.45 * 100;
 }
+
+// Similarly, test floating point conversion to bool. Only float values of zero
+// are converted to false; everything else is converted to true.
+void test1() {
+  bool b1 = 0.99f; // expected-warning {{implicit conversion from 'float' to 'bool' changes value from 0.99 to true}}
+  bool b2 = 0.99; // expected-warning {{implicit conversion from 'double' to 'bool' changes value from 0.99 to true}}
+  // These do not warn because they can be directly converted to integral
+  // values.
+  bool b3 = 0.0f;
+  bool b4 = 0.0;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6983,7 +6983,7 @@
 
   SmallString<16> PrettyTargetValue;
   if (T->isSpecificBuiltinType(BuiltinType::Bool))
-PrettyTargetValue = IntegerValue == 0 ? "false" : "true";
+PrettyTargetValue = Value.isZero() ? "false" : "true";
   else
 IntegerValue.toString(PrettyTargetValue);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-29 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

This is awesome!

LGTM with one nit: add a newline between each function definition, and two 
between each class. It's a little crowded without that.


http://reviews.llvm.org/D15813



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


Re: [PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-29 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

> This patch makes it easier to support running the lit tests for new and 
> unusual platforms. It will break existing users that set LIBCXX_TARGET_INFO 
> to anything other than the default. I think this is fine, because the old 
> LIBCXX_TARGET_INFO wasn't terribly useful.


I think @danalbert and I are the only users of out-of-tree versions of that.


http://reviews.llvm.org/D15813



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


Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-29 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

This seems to me as specific case of Clang-tidy readability-implicit-bool-cast. 
May be this check should be entirely moved to Clang?


http://reviews.llvm.org/D15814



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


Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D15814#317879, @Eugene.Zelenko wrote:

> This seems to me as specific case of Clang-tidy 
> readability-implicit-bool-cast. May be this check should be entirely moved to 
> Clang?


I think the reason why that is in clang-tidy is because it would be highly 
chatty and based on user's style preferences. This particular diagnostic has to 
do with implicit conversions that involve literals requiring conversion to the 
destination type, which are far less frequent than implicit conversions in 
general.


http://reviews.llvm.org/D15814



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


r256582 - [MS ABI] Mark an unreachable path appropriately

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 16:02:10 2015
New Revision: 256582

URL: http://llvm.org/viewvc/llvm-project?rev=256582&view=rev
Log:
[MS ABI] Mark an unreachable path appropriately

No functional change is intended, just a small cleanup.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256582&r1=256581&r2=256582&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 16:02:10 2015
@@ -395,14 +395,8 @@ void MicrosoftCXXNameMangler::mangle(con
 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
   else if (const VarDecl *VD = dyn_cast(D))
 mangleVariableEncoding(VD);
-  else {
-// TODO: Fields? Can MSVC even mangle them?
-// Issue a diagnostic for now.
-DiagnosticsEngine &Diags = Context.getDiags();
-unsigned DiagID = Diags.getCustomDiagID(
-DiagnosticsEngine::Error, "cannot mangle this declaration yet");
-Diags.Report(D->getLocation(), DiagID) << D->getSourceRange();
-  }
+  else
+llvm_unreachable("Tried to mangle unexpected NamedDecl!");
 }
 
 void MicrosoftCXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD,


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


r256583 - [MS ABI] Add a mangling for _Complex

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 16:02:15 2015
New Revision: 256583

URL: http://llvm.org/viewvc/llvm-project?rev=256583&view=rev
Log:
[MS ABI] Add a mangling for _Complex

MSVC doesn't implement a mangling for C99's _Complex so we must invent
our own.

For now, treating it like a class type called _Complex in the __clang
namespace.

This means that 'void f(__Complex int))'
will demangle as: 'void f(struct __clang::_Complex)'

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256583&r1=256582&r2=256583&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 16:02:15 2015
@@ -2207,11 +2207,16 @@ void MicrosoftCXXNameMangler::mangleType
 
 void MicrosoftCXXNameMangler::mangleType(const ComplexType *T, Qualifiers,
  SourceRange Range) {
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this complex number type yet");
-  Diags.Report(Range.getBegin(), DiagID)
-<< Range;
+  QualType ElementType = T->getElementType();
+
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+  Stream << "?$";
+  Extra.mangleSourceName("_Complex");
+  Extra.mangleType(ElementType, Range, QMM_Escape);
+
+  mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }
 
 void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=256583&r1=256582&r2=256583&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Tue Dec 29 16:02:15 2015
@@ -442,3 +442,7 @@ namespace Atomic {
 // CHECK-DAG: define void @"\01?f@Atomic@@YAXU?$_Atomic@H@__clang@@@Z"(
 void f(_Atomic(int)) {}
 }
+namespace Complex {
+// CHECK-DAG: define void @"\01?f@Complex@@YAXU?$_Complex@H@__clang@@@Z"(
+void f(_Complex int) {}
+}


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


r256585 - [TrailingObjects] Convert Decl* classes.

2015-12-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Dec 29 16:13:13 2015
New Revision: 256585

URL: http://llvm.org/viewvc/llvm-project?rev=256585&view=rev
Log:
[TrailingObjects] Convert Decl* classes.

Also remove now-redundant explicit alignment specification on some of
the classes converted prior to TrailingObjects automatically ensuring
proper alignment.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclFriend.h
cfe/trunk/include/clang/AST/DeclGroup.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclFriend.cpp
cfe/trunk/lib/AST/DeclGroup.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/AST/DeclOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=256585&r1=256584&r2=256585&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Dec 29 16:13:13 2015
@@ -1888,7 +1888,8 @@ public:
 ///   B(A& a) : A(a), f(3.14159) { }
 /// };
 /// \endcode
-class CXXCtorInitializer {
+class CXXCtorInitializer final
+: private llvm::TrailingObjects {
   /// \brief Either the base class name/delegating constructor type (stored as
   /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
   /// (IndirectFieldDecl*) being initialized.
@@ -2104,24 +2105,26 @@ public:
   /// describe an array member initialization.
   VarDecl *getArrayIndex(unsigned I) {
 assert(I < getNumArrayIndices() && "Out of bounds member array index");
-return reinterpret_cast(this + 1)[I];
+return getTrailingObjects()[I];
   }
   const VarDecl *getArrayIndex(unsigned I) const {
 assert(I < getNumArrayIndices() && "Out of bounds member array index");
-return reinterpret_cast(this + 1)[I];
+return getTrailingObjects()[I];
   }
   void setArrayIndex(unsigned I, VarDecl *Index) {
 assert(I < getNumArrayIndices() && "Out of bounds member array index");
-reinterpret_cast(this + 1)[I] = Index;
+getTrailingObjects()[I] = Index;
   }
   ArrayRef getArrayIndexes() {
 assert(getNumArrayIndices() != 0 && "Getting indexes for non-array init");
-return llvm::makeArrayRef(reinterpret_cast(this + 1),
+return llvm::makeArrayRef(getTrailingObjects(),
   getNumArrayIndices());
   }
 
   /// \brief Get the initializer.
   Expr *getInit() const { return static_cast(Init); }
+
+  friend TrailingObjects;
 };
 
 /// \brief Represents a C++ constructor within a class.

Modified: cfe/trunk/include/clang/AST/DeclFriend.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclFriend.h?rev=256585&r1=256584&r2=256585&view=diff
==
--- cfe/trunk/include/clang/AST/DeclFriend.h (original)
+++ cfe/trunk/include/clang/AST/DeclFriend.h Tue Dec 29 16:13:13 2015
@@ -37,7 +37,9 @@ namespace clang {
 /// @endcode
 ///
 /// The semantic context of a friend decl is its declaring class.
-class FriendDecl : public Decl {
+class FriendDecl final
+: public Decl,
+  private llvm::TrailingObjects {
   virtual void anchor();
 public:
   typedef llvm::PointerUnion FriendUnion;
@@ -62,14 +64,6 @@ private:
   // template  friend class A::B;
   unsigned NumTPLists : 31;
 
-  // The tail-allocated friend type template parameter lists (if any).
-  TemplateParameterList* const *getTPLists() const {
-return reinterpret_cast(this + 1);
-  }
-  TemplateParameterList **getTPLists() {
-return reinterpret_cast(this + 1);
-  }
-
   friend class CXXRecordDecl::friend_iterator;
   friend class CXXRecordDecl;
 
@@ -83,7 +77,7 @@ private:
   UnsupportedFriend(false),
   NumTPLists(FriendTypeTPLists.size()) {
 for (unsigned i = 0; i < NumTPLists; ++i)
-  getTPLists()[i] = FriendTypeTPLists[i];
+  getTrailingObjects()[i] = FriendTypeTPLists[i];
   }
 
   FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
@@ -118,7 +112,7 @@ public:
   }
   TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const {
 assert(N < NumTPLists);
-return getTPLists()[N];
+return getTrailingObjects()[N];
   }
 
   /// If this friend declaration doesn't name a type, return the inner
@@ -148,9 +142,10 @@ public:
   return SourceRange(getFriendLoc(), ND->getLocEnd());
 }
 else if (TypeSourceInfo *TInfo = getFriendType()) {
-  SourceLocation StartL = (NumTPLists == 0)
-? getFriendLoc()
-: getTPLists()[0]->getTemplateLoc();
+  SourceLocation StartL =
+  (NumTPLists == 0) ? getFriendLoc()
+: getTrailingObjects()[0]
+  ->getTemplateLoc();

r256587 - Use consistent types for all bit-field members in the same bit-field so that MSVC's bit-field packing algorithm packs them properly.

2015-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 29 16:19:20 2015
New Revision: 256587

URL: http://llvm.org/viewvc/llvm-project?rev=256587&view=rev
Log:
Use consistent types for all bit-field members in the same bit-field so that 
MSVC's bit-field packing algorithm packs them properly.

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256587&r1=256586&r2=256587&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 29 16:19:20 2015
@@ -1558,25 +1558,25 @@ private:
 
   LazyDeclStmtPtr Body;
 
-  // FIXME: This can be packed into the bitfields in Decl.
-  // NOTE: VC++ treats enums as signed, avoid using the StorageClass enum
+  // FIXME: This can be packed into the bitfields in DeclContext.
+  // NOTE: VC++ packs bitfields poorly if the types differ.
   unsigned SClass : 2;
-  bool IsInline : 1;
-  bool IsInlineSpecified : 1;
-  bool IsVirtualAsWritten : 1;
-  bool IsPure : 1;
-  bool HasInheritedPrototype : 1;
-  bool HasWrittenPrototype : 1;
-  bool IsDeleted : 1;
-  bool IsTrivial : 1; // sunk from CXXMethodDecl
-  bool IsDefaulted : 1; // sunk from CXXMethoDecl
-  bool IsExplicitlyDefaulted : 1; //sunk from CXXMethodDecl
-  bool HasImplicitReturnZero : 1;
-  bool IsLateTemplateParsed : 1;
-  bool IsConstexpr : 1;
+  unsigned IsInline : 1;
+  unsigned IsInlineSpecified : 1;
+  unsigned IsVirtualAsWritten : 1;
+  unsigned IsPure : 1;
+  unsigned HasInheritedPrototype : 1;
+  unsigned HasWrittenPrototype : 1;
+  unsigned IsDeleted : 1;
+  unsigned IsTrivial : 1; // sunk from CXXMethodDecl
+  unsigned IsDefaulted : 1; // sunk from CXXMethoDecl
+  unsigned IsExplicitlyDefaulted : 1; //sunk from CXXMethodDecl
+  unsigned HasImplicitReturnZero : 1;
+  unsigned IsLateTemplateParsed : 1;
+  unsigned IsConstexpr : 1;
 
   /// \brief Indicates if the function uses __try.
-  bool UsesSEHTry : 1;
+  unsigned UsesSEHTry : 1;
 
   /// \brief Indicates if the function was a definition but its body was
   /// skipped.


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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-12-29 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 43761.
LegalizeAdulthood added a comment.

Regenerate documentation from dump_ast_matchers.py


http://reviews.llvm.org/D8149

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,12 @@
   EXPECT_TRUE(matches("void f(int i) {}", functionType()));
 }
 
+TEST(TypeMatching, MatchesFunctionProtoTypes) {
+  EXPECT_TRUE(matches("int (*f)(int);", functionProtoType()));
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+}
+
 TEST(TypeMatching, MatchesParenType) {
   EXPECT_TRUE(
   matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType());
@@ -4977,6 +4983,11 @@
   namespaceDecl(isInline(), hasName("m";
 }
 
+TEST(HasUnderlyingTypeMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+}
+
 // FIXME: Figure out how to specify paths so the following tests pass on Windows.
 #ifndef LLVM_ON_WIN32
 
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -181,6 +181,7 @@
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
+  REGISTER_MATCHER(functionProtoType);
   REGISTER_MATCHER(functionTemplateDecl);
   REGISTER_MATCHER(functionType);
   REGISTER_MATCHER(gotoStmt);
@@ -248,6 +249,7 @@
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);
+  REGISTER_MATCHER(hasUnderlyingType);
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -168,6 +168,21 @@
 ///   matches "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches the underlying type of a typedef declaration
+///
+/// Given
+/// \code
+///   typedef int X;
+///   typedef float Y;
+/// \endcode
+/// typedefDecl(hasUnderlyingType(asString("int")))
+///   matches "typedef int X"
+AST_MATCHER_P(TypedefDecl, hasUnderlyingType, internal::Matcher,
+  InnerMatcher) {
+  QualType UnderlyingType = Node.getUnderlyingType();
+  return InnerMatcher.matches(UnderlyingType, Finder, Builder);
+}
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2889,16 +2904,24 @@
 Node.param_end(), Finder, Builder);
 }
 
-/// \brief Matches \c FunctionDecls that have a specific parameter count.
+/// \brief Matches \c FunctionDecls and FunctionProtoTypes that have a specific
+/// parameter count.
 ///
 /// Given
 /// \code
 ///   void f(int i) {}
 ///   void g(int i, int j) {}
+///   void h(int i, int j);
+///   void j(int i);
 /// \endcode
 /// functionDecl(parameterCountIs(2))
-///   matches g(int i, int j) {}
-AST_MATCHER_P(FunctionDecl, parameterCountIs, unsigned, N) {
+///   matches void g(int i, int j) {}
+/// functionProtoType(parameterCountIs(2))
+///   matches void h(int i, int j)
+AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+  FunctionProtoType),
+  unsigned, N) {
   return Node.getNumParams() == N;
 }
 
@@ -3988,6 +4011,17 @@
 ///   matches "int (*f)(int)" and the type of "g".
 AST_TYPE_MATCHER(FunctionType, functionType);
 
+/// \brief Matches \c FunctionProtoType nodes.
+///
+/// Given
+/// \code
+///   int (*f)(int);
+///   void g();
+/// \endcode
+/// functionProtoType()
+///   matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);
+
 /// \brief Matches \c ParenType nodes.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1299,6 +1299,17 @@
 
 
 
+MatcherType>functionProtoTypeMatcherFunctionProtoType>...
+Matches FunctionProtoType nodes.
+
+Given
+  int (*f)(int);
+  void g();
+functionProtoType()
+  matches "int (*f)(int)" and the type of "g".
+
+
+
 Matcher<

[libcxx] r256588 - [libcxx] Refactoring target_info.py

2015-12-29 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Dec 29 16:21:38 2015
New Revision: 256588

URL: http://llvm.org/viewvc/llvm-project?rev=256588&view=rev
Log:
[libcxx] Refactoring target_info.py

This patch makes it easier to support running the lit tests for new and
unusual platforms. It will break existing users that set
LIBCXX_TARGET_INFO to anything other than the default. I think this is
fine, because the old LIBCXX_TARGET_INFO wasn't terribly useful.

The old way of supporting the different test platforms was to have
conditional code scattered throughout config.py. New platforms would need
to add conditionals there. Alternatively, the new platform could set
no_default_flags to true, and reconstitue almost the entire compile and
link line, including things that don't vary across platforms.

The new way of supporting new platforms is to create a new target info
class, and have make_target_info return an instance of it. For platforms
supported in-tree, that will be done by modifying make_target_info. For
out-of-tree platforms, users can set LIBCXX_TARGET_INFO at cmake configure
time.

The target info sub-classes can provide fine-grained information back to
config.py. The hooks that will most commonly be provided will be
add_cxx_compile_flags and add_cxx_link_flags. These hooks can provide the
platform specific flags, while letting config.py handle all the invariant
flags.

Target info hooks were added for each area that the existing config.py had
platform specific behavior. config.py is now mostly free of platform
specific conditionals.

This patch was tested on Linux x86_64. I both targeted Linux x86_64, and
an out-of-tree platform with a custom target_info. In both cases I was
able to run libcxx and libcxxabi tests. I do not have access to FreeBSD,
Darwin, or Windows machines that are set up for lit testing.

Modified:
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=256588&r1=256587&r2=256588&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Dec 29 16:21:38 2015
@@ -1,4 +1,3 @@
-import importlib
 import locale
 import os
 import platform
@@ -12,6 +11,7 @@ import lit.util  # pylint: disable=impor
 
 from libcxx.test.format import LibcxxTestFormat
 from libcxx.compiler import CXXCompiler
+from libcxx.test.target_info import make_target_info
 from libcxx.test.executor import *
 from libcxx.test.tracing import *
 
@@ -42,22 +42,6 @@ def loadSiteConfig(lit_config, config, p
 ld_fn(config, site_cfg)
 lit_config.load_config = ld_fn
 
-def getSysrootFlagsOnDarwin(config, lit_config):
-# On Darwin, support relocatable SDKs by providing Clang with a
-# default system root path.
-if 'darwin' in config.target_triple:
-try:
-out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
-res = 0
-except OSError:
-res = -1
-if res == 0 and out:
-sdk_path = out
-lit_config.note('using SDKROOT: %r' % sdk_path)
-return ["-isysroot", sdk_path]
-return []
-
-
 class Configuration(object):
 # pylint: disable=redefined-outer-name
 def __init__(self, lit_config, config):
@@ -157,13 +141,7 @@ class Configuration(object):
 self.executor = te
 
 def configure_target_info(self):
-default = "libcxx.test.target_info.LocalTI"
-info_str = self.get_lit_conf('target_info', default)
-mod_path, _, info = info_str.rpartition('.')
-mod = importlib.import_module(mod_path)
-self.target_info = getattr(mod, info)()
-if info_str != default:
-self.lit_config.note("inferred target_info as: %r" % info_str)
+self.target_info = make_target_info(self)
 
 def configure_cxx(self):
 # Gather various compiler parameters.
@@ -234,13 +212,12 @@ class Configuration(object):
 def configure_execute_external(self):
 # Choose between lit's internal shell pipeline runner and a real shell.
 # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
-# default value. Otherwise we default to internal on Windows and
-# external elsewhere, as bash on Windows is usually very slow.
+# default value. Otherwise we ask the target_info.
 use_lit_shell_default = os.environ.get('LIT_USE_INTERNAL_SHELL')
 if use_lit_shell_default is not None:
 use_lit_shell_default = use_lit_shell_default != '0'
 else:
-use_lit_shell_default = sys.platform == 'win32'
+use_lit_shell_default = self.target_info.use_lit_shell_default()
 # Check for the command line parameter using the default value if it is
 # not present.
 use_lit_shell = se

r256589 - [MS ABI] Invent a mangling for reference temporaries

2015-12-29 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec 29 16:25:14 2015
New Revision: 256589

URL: http://llvm.org/viewvc/llvm-project?rev=256589&view=rev
Log:
[MS ABI] Invent a mangling for reference temporaries

MSVC is non-conforming and doesn't have a mangling for these.  Invent
our own to unblock folks using clang.

This fixes PR25795.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=256589&r1=256588&r2=256589&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec 29 16:25:14 2015
@@ -2760,12 +2760,12 @@ void MicrosoftMangleContextImpl::mangleC
   mangler.mangle(D);
 }
 
-void MicrosoftMangleContextImpl::mangleReferenceTemporary(const VarDecl *VD,
-  unsigned,
-  raw_ostream &) {
-  unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this reference temporary yet");
-  getDiags().Report(VD->getLocation(), DiagID);
+void MicrosoftMangleContextImpl::mangleReferenceTemporary(
+const VarDecl *VD, unsigned ManglingNumber, raw_ostream &Out) {
+  MicrosoftCXXNameMangler Mangler(*this, Out);
+
+  Mangler.getStream() << "\01?$RT" << ManglingNumber << '@';
+  Mangler.mangle(VD, "");
 }
 
 void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=256589&r1=256588&r2=256589&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Tue Dec 29 16:25:14 2015
@@ -21,6 +21,10 @@ int _c(void) {return N::anonymous + c;}
 // CHECK-DAG: @"\01?_c@@YAHXZ"
 // X64-DAG:   @"\01?_c@@YAHXZ"
 
+const int &NeedsReferenceTemporary = 2;
+// CHECK-DAG: @"\01?NeedsReferenceTemporary@@3ABHB" = constant i32* 
@"\01?$RT1@NeedsReferenceTemporary@@3ABHB"
+// X64-DAG: @"\01?NeedsReferenceTemporary@@3AEBHEB" = constant i32* 
@"\01?$RT1@NeedsReferenceTemporary@@3AEBHEB"
+
 class foo {
   static const short d;
 // CHECK-DAG: @"\01?d@foo@@0FB"


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


Re: [PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-29 Thread Ben Craig via cfe-commits
bcraig closed this revision.
bcraig added a comment.

Committed as r256588.
Thanks for the quick review!


http://reviews.llvm.org/D15813



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


r256590 - [TrailingObjects] Convert OffsetOfExpr.

2015-12-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Dec 29 16:31:18 2015
New Revision: 256590

URL: http://llvm.org/viewvc/llvm-project?rev=256590&view=rev
Log:
[TrailingObjects] Convert OffsetOfExpr.

That necessitated moving the OffsetOfNode class out of OffsetOfExpr.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=256590&r1=256589&r2=256590&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Dec 29 16:31:18 2015
@@ -1749,6 +1749,99 @@ public:
   child_range children() { return child_range(&Val, &Val+1); }
 };
 
+/// Helper class for OffsetOfExpr.
+
+// __builtin_offsetof(type, identifier(.identifier|[expr])*)
+class OffsetOfNode {
+public:
+  /// \brief The kind of offsetof node we have.
+  enum Kind {
+/// \brief An index into an array.
+Array = 0x00,
+/// \brief A field.
+Field = 0x01,
+/// \brief A field in a dependent type, known only by its name.
+Identifier = 0x02,
+/// \brief An implicit indirection through a C++ base class, when the
+/// field found is in a base class.
+Base = 0x03
+  };
+
+private:
+  enum { MaskBits = 2, Mask = 0x03 };
+
+  /// \brief The source range that covers this part of the designator.
+  SourceRange Range;
+
+  /// \brief The data describing the designator, which comes in three
+  /// different forms, depending on the lower two bits.
+  ///   - An unsigned index into the array of Expr*'s stored after this node
+  /// in memory, for [constant-expression] designators.
+  ///   - A FieldDecl*, for references to a known field.
+  ///   - An IdentifierInfo*, for references to a field with a given name
+  /// when the class type is dependent.
+  ///   - A CXXBaseSpecifier*, for references that look at a field in a
+  /// base class.
+  uintptr_t Data;
+
+public:
+  /// \brief Create an offsetof node that refers to an array element.
+  OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
+   SourceLocation RBracketLoc)
+  : Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) {}
+
+  /// \brief Create an offsetof node that refers to a field.
+  OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field, SourceLocation NameLoc)
+  : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
+Data(reinterpret_cast(Field) | OffsetOfNode::Field) {}
+
+  /// \brief Create an offsetof node that refers to an identifier.
+  OffsetOfNode(SourceLocation DotLoc, IdentifierInfo *Name,
+   SourceLocation NameLoc)
+  : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
+Data(reinterpret_cast(Name) | Identifier) {}
+
+  /// \brief Create an offsetof node that refers into a C++ base class.
+  explicit OffsetOfNode(const CXXBaseSpecifier *Base)
+  : Range(), Data(reinterpret_cast(Base) | OffsetOfNode::Base) 
{}
+
+  /// \brief Determine what kind of offsetof node this is.
+  Kind getKind() const { return static_cast(Data & Mask); }
+
+  /// \brief For an array element node, returns the index into the array
+  /// of expressions.
+  unsigned getArrayExprIndex() const {
+assert(getKind() == Array);
+return Data >> 2;
+  }
+
+  /// \brief For a field offsetof node, returns the field.
+  FieldDecl *getField() const {
+assert(getKind() == Field);
+return reinterpret_cast(Data & ~(uintptr_t)Mask);
+  }
+
+  /// \brief For a field or identifier offsetof node, returns the name of
+  /// the field.
+  IdentifierInfo *getFieldName() const;
+
+  /// \brief For a base class node, returns the base specifier.
+  CXXBaseSpecifier *getBase() const {
+assert(getKind() == Base);
+return reinterpret_cast(Data & ~(uintptr_t)Mask);
+  }
+
+  /// \brief Retrieve the source range that covers this offsetof node.
+  ///
+  /// For an array element node, the source range contains the locations of
+  /// the square brackets. For a field or identifier node, the source range
+  /// contains the location of the period (if there is one) and the
+  /// identifier.
+  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
+  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
+  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
+};
+
 /// OffsetOfExpr - [C99 7.17] - This represents an expression of the form
 /// offsetof(record-type, member-designator). For example, given:
 /// @code
@@ -1763,104 +1856,9 @@ publi

[libcxx] r256591 - [libcxx] Fixing the Linux sanitizer builds

2015-12-29 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Dec 29 16:43:17 2015
New Revision: 256591

URL: http://llvm.org/viewvc/llvm-project?rev=256591&view=rev
Log:
[libcxx] Fixing the Linux sanitizer builds

Modified:
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=256591&r1=256590&r2=256591&view=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Tue Dec 29 16:43:17 2015
@@ -142,7 +142,8 @@ class LinuxLocalTI(DefaultTargetInfo):
 flags += ['-lunwind', '-ldl']
 else:
 flags += ['-lgcc_s', '-lgcc']
-if self.full_config.get_lit_bool('use_sanitizer', False):
+san = self.get_lit_conf('use_sanitizer', '').strip()
+if san:
 # The libraries and their order are taken from the
 # linkSanitizerRuntimeDeps function in
 # clang/lib/Driver/Tools.cpp


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


[libcxx] r256592 - [libcxx] Fixing silly mistake from last commit.

2015-12-29 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Dec 29 16:55:55 2015
New Revision: 256592

URL: http://llvm.org/viewvc/llvm-project?rev=256592&view=rev
Log:
[libcxx] Fixing silly mistake from last commit.

Tested on Linux x86_64 targeting Linux x86_64.

Modified:
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=256592&r1=256591&r2=256592&view=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Tue Dec 29 16:55:55 2015
@@ -142,7 +142,7 @@ class LinuxLocalTI(DefaultTargetInfo):
 flags += ['-lunwind', '-ldl']
 else:
 flags += ['-lgcc_s', '-lgcc']
-san = self.get_lit_conf('use_sanitizer', '').strip()
+san = self.full_config.get_lit_conf('use_sanitizer', '').strip()
 if san:
 # The libraries and their order are taken from the
 # linkSanitizerRuntimeDeps function in


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


[libcxx] r256594 - [libcxx] Fixing the Mac / Darwin build

2015-12-29 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Dec 29 17:01:07 2015
New Revision: 256594

URL: http://llvm.org/viewvc/llvm-project?rev=256594&view=rev
Log:
[libcxx] Fixing the Mac / Darwin build

Modified:
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=256594&r1=256593&r2=256594&view=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Tue Dec 29 17:01:07 2015
@@ -1,4 +1,5 @@
 import importlib
+import lit.util  # pylint: disable=import-error,no-name-in-module
 import locale
 import os
 import platform


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


r256595 - Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

2015-12-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Dec 29 17:06:17 2015
New Revision: 256595

URL: http://llvm.org/viewvc/llvm-project?rev=256595&view=rev
Log:
Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/TokenLexer.h
cfe/trunk/lib/Lex/PPLexerChange.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/macro_paste_msextensions.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256595&r1=256594&r2=256595&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29 17:06:17 2015
@@ -765,6 +765,7 @@ def MicrosoftCast : DiagGroup<"microsoft
 def MicrosoftConstInit : DiagGroup<"microsoft-const-init">;
 def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
 def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
+def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
 // Aliases.
 def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // -Wmsvc-include = -Wmicrosoft-include
@@ -778,7 +779,8 @@ def Microsoft : DiagGroup<"microsoft",
  MicrosoftEnumValue, MicrosoftDefaultArgRedefinition, MicrosoftTemplate,
  MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto,
  MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
- MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>;
+ MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
+ MicrosoftCommentPaste]>;
 
 def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256595&r1=256594&r2=256595&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29 17:06:17 2015
@@ -59,6 +59,9 @@ def ext_dollar_in_identifier : Extension
 def ext_charize_microsoft : Extension<
   "charizing operator #@ is a Microsoft extension">,
   InGroup;
+def ext_comment_paste_microsoft : Extension<
+  "pasting two '/' tokens into a '//' comment token is a Microsoft extension">,
+  InGroup;
 
 def ext_token_used : Extension<"extension used">,
   InGroup>;

Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=256595&r1=256594&r2=256595&view=diff
==
--- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
+++ cfe/trunk/include/clang/Lex/TokenLexer.h Tue Dec 29 17:06:17 2015
@@ -175,7 +175,7 @@ private:
   /// macro, other active macros, and anything left on the current physical
   /// source line of the expanded buffer.  Handle this by returning the
   /// first token on the next line.
-  void HandleMicrosoftCommentPaste(Token &Tok);
+  void HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc);
 
   /// \brief If \p loc is a FileID and points inside the current macro
   /// definition, returns the appropriate source location pointing at the

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=256595&r1=256594&r2=256595&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Dec 29 17:06:17 2015
@@ -561,7 +561,6 @@ void Preprocessor::RemoveTopOfLexerStack
 void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
   assert(CurTokenLexer && !CurPPLexer &&
  "Pasted comment can only be formed from macro");
-
   // We handle this by scanning for the closest real lexer, switching it to
   // raw mode and preprocessor mode.  This will cause it to return \n as an
   // explicit EOD token.

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=256595&r1=256594&r2=256595&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Tue Dec 29 17:06:17 2015
@@ -624,21 +624,22 @@ bool TokenLexer::PasteTokens(Token &Tok)
   // error.  This occurs with "x ## +"  and other stuff.  Return with Tok
   // unmodified and with RHS as the next token to lex.
   if (isInvalid) {
+// Explicitly convert the token location to have proper expansion
+// in

Re: r256595 - Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

2015-12-29 Thread Richard Smith via cfe-commits
On Tue, Dec 29, 2015 at 3:06 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Tue Dec 29 17:06:17 2015
> New Revision: 256595
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256595&view=rev
> Log:
> Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS
> mode.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Lex/TokenLexer.h
> cfe/trunk/lib/Lex/PPLexerChange.cpp
> cfe/trunk/lib/Lex/TokenLexer.cpp
> cfe/trunk/test/Preprocessor/macro_paste_msextensions.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256595&r1=256594&r2=256595&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29 17:06:17
> 2015
> @@ -765,6 +765,7 @@ def MicrosoftCast : DiagGroup<"microsoft
>  def MicrosoftConstInit : DiagGroup<"microsoft-const-init">;
>  def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
>  def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
> +def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
>  // Aliases.
>  def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
>  // -Wmsvc-include = -Wmicrosoft-include
> @@ -778,7 +779,8 @@ def Microsoft : DiagGroup<"microsoft",
>   MicrosoftEnumValue, MicrosoftDefaultArgRedefinition,
> MicrosoftTemplate,
>   MicrosoftRedeclareStatic, MicrosoftEnumForwardReference,
> MicrosoftGoto,
>   MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
> - MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>;
> + MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
> + MicrosoftCommentPaste]>;
>
>  def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
>
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256595&r1=256594&r2=256595&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29
> 17:06:17 2015
> @@ -59,6 +59,9 @@ def ext_dollar_in_identifier : Extension
>  def ext_charize_microsoft : Extension<
>"charizing operator #@ is a Microsoft extension">,
>InGroup;
> +def ext_comment_paste_microsoft : Extension<
> +  "pasting two '/' tokens into a '//' comment token is a Microsoft
> extension">,
>

It's not really technically correct to call this a token. Maybe drop the
word "token" here?


> +  InGroup;
>
>  def ext_token_used : Extension<"extension used">,
>InGroup>;
>
> Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=256595&r1=256594&r2=256595&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
> +++ cfe/trunk/include/clang/Lex/TokenLexer.h Tue Dec 29 17:06:17 2015
> @@ -175,7 +175,7 @@ private:
>/// macro, other active macros, and anything left on the current
> physical
>/// source line of the expanded buffer.  Handle this by returning the
>/// first token on the next line.
> -  void HandleMicrosoftCommentPaste(Token &Tok);
> +  void HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc);
>
>/// \brief If \p loc is a FileID and points inside the current macro
>/// definition, returns the appropriate source location pointing at the
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=256595&r1=256594&r2=256595&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Dec 29 17:06:17 2015
> @@ -561,7 +561,6 @@ void Preprocessor::RemoveTopOfLexerStack
>  void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
>assert(CurTokenLexer && !CurPPLexer &&
>   "Pasted comment can only be formed from macro");
> -
>// We handle this by scanning for the closest real lexer, switching it
> to
>// raw mode and preprocessor mode.  This will cause it to return \n as
> an
>// explicit EOD token.
>
> Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=256595&r1=256594&r2=256595&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/TokenLexer.c

r256596 - Emit a -Wmicrosoft warning when treating ^Z as EOF in MS mode.

2015-12-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Dec 29 17:17:27 2015
New Revision: 256596

URL: http://llvm.org/viewvc/llvm-project?rev=256596&view=rev
Log:
Emit a -Wmicrosoft warning when treating ^Z as EOF in MS mode.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Lexer/msdos-cpm-eof.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256596&r1=256595&r2=256596&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29 17:17:27 2015
@@ -766,6 +766,7 @@ def MicrosoftConstInit : DiagGroup<"micr
 def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
 def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
 def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
+def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">;
 // Aliases.
 def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // -Wmsvc-include = -Wmicrosoft-include
@@ -780,7 +781,7 @@ def Microsoft : DiagGroup<"microsoft",
  MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto,
  MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
  MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
- MicrosoftCommentPaste]>;
+ MicrosoftCommentPaste, MicrosoftEndOfFile]>;
 
 def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256596&r1=256595&r2=256596&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29 17:17:27 2015
@@ -62,6 +62,9 @@ def ext_charize_microsoft : Extension<
 def ext_comment_paste_microsoft : Extension<
   "pasting two '/' tokens into a '//' comment token is a Microsoft extension">,
   InGroup;
+def ext_ctrl_z_eof_microsoft : Extension<
+  "treating Ctrl-Z as end-of-file is a Microsoft extension">,
+  InGroup;
 
 def ext_token_used : Extension<"extension used">,
   InGroup>;

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=256596&r1=256595&r2=256596&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Dec 29 17:17:27 2015
@@ -2960,8 +2960,11 @@ LexNextToken:
   
   case 26:  // DOS & CP/M EOF: "^Z".
 // If we're in Microsoft extensions mode, treat this as end of file.
-if (LangOpts.MicrosoftExt)
+if (LangOpts.MicrosoftExt) {
+  if (!isLexingRawMode())
+Diag(CurPtr-1, diag::ext_ctrl_z_eof_microsoft);
   return LexEndOfFile(Result, CurPtr-1);
+}
 
 // If Microsoft extensions are disabled, this is just random garbage.
 Kind = tok::unknown;

Modified: cfe/trunk/test/Lexer/msdos-cpm-eof.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/msdos-cpm-eof.c?rev=256596&r1=256595&r2=256596&view=diff
==
--- cfe/trunk/test/Lexer/msdos-cpm-eof.c (original)
+++ cfe/trunk/test/Lexer/msdos-cpm-eof.c Tue Dec 29 17:17:27 2015
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -Wmicrosoft %s
 
 int x; 
 
+// expected-warning@+1 {{treating Ctrl-Z as end-of-file is a Microsoft 
extension">,
 
 
 I am random garbage after ^Z


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


[libcxx] r256597 - Mark LWG defect #2367 as complete

2015-12-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 29 17:18:27 2015
New Revision: 256597

URL: http://llvm.org/viewvc/llvm-project?rev=256597&view=rev
Log:
Mark LWG defect #2367 as complete

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=256597&r1=256596&r2=256597&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Dec 29 17:18:27 2015
@@ -165,7 +165,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2273";>2273regex_match
 ambiguityKona
http://cplusplus.github.io/LWG/lwg-defects.html#2336";>2336is_trivially_constructible/is_trivially_assignable
 traits are always falseKona
http://cplusplus.github.io/LWG/lwg-defects.html#2353";>2353std::next
 is over-constrainedKonaComplete
-   http://cplusplus.github.io/LWG/lwg-defects.html#2367";>2367pair
 and tuple are not correctly implemented for is_constructible 
with no argsKonaPatch Ready
+   http://cplusplus.github.io/LWG/lwg-defects.html#2367";>2367pair
 and tuple are not correctly implemented for is_constructible 
with no argsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2380";>2380May
  provide long ::abs(long) and long long 
::abs(long long)?KonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2384";>2384Allocator's
 deallocate function needs better 
specificationKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2385";>2385function::assign
 allocator argument doesn't make senseKona


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


[libcxx] r256598 - Fix test failure in 32 bit mode

2015-12-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 29 17:19:00 2015
New Revision: 256598

URL: http://llvm.org/viewvc/llvm-project?rev=256598&view=rev
Log:
Fix test failure in 32 bit mode

Modified:
libcxx/trunk/test/libcxx/experimental/any/small_type.pass.cpp

Modified: libcxx/trunk/test/libcxx/experimental/any/small_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/any/small_type.pass.cpp?rev=256598&r1=256597&r2=256598&view=diff
==
--- libcxx/trunk/test/libcxx/experimental/any/small_type.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/experimental/any/small_type.pass.cpp Tue Dec 29 
17:19:00 2015
@@ -16,6 +16,12 @@
 #include 
 #include "any_helpers.h"
 
+constexpr std::size_t BufferSize = (sizeof(void*) * 3);
+constexpr std::size_t BufferAlignment = alignof(void*);
+// Clang doesn't like "alignof(BufferAlignment * 2)" due to PR13986.
+// So we create "DoubleBufferAlignment" instead.
+constexpr std::size_t DoubleBufferAlignment = BufferAlignment * 2;
+
 class SmallThrowsDtor
 {
 public:
@@ -25,6 +31,30 @@ public:
 ~SmallThrowsDtor() noexcept(false) {}
 };
 
+
+struct alignas(1) MaxSizeType {
+char buff[BufferSize];
+};
+
+struct alignas(BufferAlignment) MaxAlignType {
+};
+
+struct alignas(BufferAlignment) MaxSizeAndAlignType {
+char buff[BufferSize];
+};
+
+
+struct alignas(1) OverSizeType {
+char buff[BufferSize + 1];
+};
+
+struct alignas(DoubleBufferAlignment) OverAlignedType {
+};
+
+struct alignas(DoubleBufferAlignment) OverSizeAndAlignedType {
+char buff[BufferSize + 1];
+};
+
 int main()
 {
 using std::experimental::any;
@@ -33,8 +63,52 @@ int main()
 static_assert(_IsSmallObject::value, "");
 static_assert(!_IsSmallObject::value, "");
 static_assert(!_IsSmallObject::value, "");
-// long double is over aligned.
-static_assert(sizeof(long double) <= sizeof(void*) * 3, "");
-static_assert(alignof(long double) > alignof(void*), "");
-static_assert(!_IsSmallObject::value, "");
+{
+// Check a type that meets the size requirement *exactly* and has
+// a lesser alignment requirement is considered small.
+typedef MaxSizeType T;
+static_assert(sizeof(T) == BufferSize, "");
+static_assert(alignof(T) < BufferAlignment,   "");
+static_assert(_IsSmallObject::value, "");
+}
+{
+// Check a type that meets the alignment requirement *exactly* and has
+// a lesser size is considered small.
+typedef MaxAlignType T;
+static_assert(sizeof(T) < BufferSize, "");
+static_assert(alignof(T) == BufferAlignment,   "");
+static_assert(_IsSmallObject::value, "");
+}
+{
+// Check a type that meets the size and alignment requirements 
*exactly*
+// is considered small.
+typedef MaxSizeAndAlignType T;
+static_assert(sizeof(T) == BufferSize, "");
+static_assert(alignof(T) == BufferAlignment,   "");
+static_assert(_IsSmallObject::value, "");
+}
+{
+// Check a type that meets the alignment requirements but is over-sized
+// is not considered small.
+typedef OverSizeType T;
+static_assert(sizeof(T) > BufferSize, "");
+static_assert(alignof(T) < BufferAlignment, "");
+static_assert(!_IsSmallObject::value, "");
+}
+{
+// Check a type that meets the size requirements but is over-aligned
+// is not considered small.
+typedef OverAlignedType T;
+static_assert(sizeof(T) < BufferSize, "");
+static_assert(alignof(T) > BufferAlignment, "");
+static_assert(!_IsSmallObject::value, "");
+}
+{
+// Check a type that exceeds both the size an alignment requirements
+// is not considered small.
+typedef OverSizeAndAlignedType T;
+static_assert(sizeof(T) > BufferSize, "");
+static_assert(alignof(T) > BufferAlignment, "");
+static_assert(!_IsSmallObject::value, "");
+}
 }


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


Re: r256595 - Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

2015-12-29 Thread Nico Weber via cfe-commits
On Tue, Dec 29, 2015 at 6:16 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Dec 29, 2015 at 3:06 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: nico
>> Date: Tue Dec 29 17:06:17 2015
>> New Revision: 256595
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256595&view=rev
>> Log:
>> Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS
>> mode.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Lex/TokenLexer.h
>> cfe/trunk/lib/Lex/PPLexerChange.cpp
>> cfe/trunk/lib/Lex/TokenLexer.cpp
>> cfe/trunk/test/Preprocessor/macro_paste_msextensions.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256595&r1=256594&r2=256595&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29 17:06:17
>> 2015
>> @@ -765,6 +765,7 @@ def MicrosoftCast : DiagGroup<"microsoft
>>  def MicrosoftConstInit : DiagGroup<"microsoft-const-init">;
>>  def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
>>  def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
>> +def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
>>  // Aliases.
>>  def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
>>  // -Wmsvc-include = -Wmicrosoft-include
>> @@ -778,7 +779,8 @@ def Microsoft : DiagGroup<"microsoft",
>>   MicrosoftEnumValue, MicrosoftDefaultArgRedefinition,
>> MicrosoftTemplate,
>>   MicrosoftRedeclareStatic, MicrosoftEnumForwardReference,
>> MicrosoftGoto,
>>   MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
>> - MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>;
>> + MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
>> + MicrosoftCommentPaste]>;
>>
>>  def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
>>
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256595&r1=256594&r2=256595&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29
>> 17:06:17 2015
>> @@ -59,6 +59,9 @@ def ext_dollar_in_identifier : Extension
>>  def ext_charize_microsoft : Extension<
>>"charizing operator #@ is a Microsoft extension">,
>>InGroup;
>> +def ext_comment_paste_microsoft : Extension<
>> +  "pasting two '/' tokens into a '//' comment token is a Microsoft
>> extension">,
>>
>
> It's not really technically correct to call this a token. Maybe drop the
> word "token" here?
>

Thanks for the review! You mean only the second "token", not the first
"tokens", right?


>
>
>> +  InGroup;
>>
>>  def ext_token_used : Extension<"extension used">,
>>InGroup>;
>>
>> Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=256595&r1=256594&r2=256595&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
>> +++ cfe/trunk/include/clang/Lex/TokenLexer.h Tue Dec 29 17:06:17 2015
>> @@ -175,7 +175,7 @@ private:
>>/// macro, other active macros, and anything left on the current
>> physical
>>/// source line of the expanded buffer.  Handle this by returning the
>>/// first token on the next line.
>> -  void HandleMicrosoftCommentPaste(Token &Tok);
>> +  void HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc);
>>
>>/// \brief If \p loc is a FileID and points inside the current macro
>>/// definition, returns the appropriate source location pointing at the
>>
>> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=256595&r1=256594&r2=256595&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Dec 29 17:06:17 2015
>> @@ -561,7 +561,6 @@ void Preprocessor::RemoveTopOfLexerStack
>>  void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
>>assert(CurTokenLexer && !CurPPLexer &&
>>   "Pasted comment can only be formed from macro");
>> -
>>// We handle this by scanning for the closest real lexer, switching it
>> to
>>// raw mode and preprocessor mode.  This will cause it to return \n as
>> an
>>

r256599 - Fix test from r256596

2015-12-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Dec 29 17:23:38 2015
New Revision: 256599

URL: http://llvm.org/viewvc/llvm-project?rev=256599&view=rev
Log:
Fix test from r256596

Modified:
cfe/trunk/test/Lexer/msdos-cpm-eof.c

Modified: cfe/trunk/test/Lexer/msdos-cpm-eof.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/msdos-cpm-eof.c?rev=256599&r1=256598&r2=256599&view=diff
==
--- cfe/trunk/test/Lexer/msdos-cpm-eof.c (original)
+++ cfe/trunk/test/Lexer/msdos-cpm-eof.c Tue Dec 29 17:23:38 2015
@@ -2,7 +2,7 @@
 
 int x; 
 
-// expected-warning@+1 {{treating Ctrl-Z as end-of-file is a Microsoft 
extension">,
+// expected-warning@+1 {{treating Ctrl-Z as end-of-file is a Microsoft 
extension}}
 
 
 I am random garbage after ^Z


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


Re: r256595 - Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

2015-12-29 Thread Richard Smith via cfe-commits
On Tue, Dec 29, 2015 at 3:23 PM, Nico Weber  wrote:

> On Tue, Dec 29, 2015 at 6:16 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Tue, Dec 29, 2015 at 3:06 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: nico
>>> Date: Tue Dec 29 17:06:17 2015
>>> New Revision: 256595
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=256595&view=rev
>>> Log:
>>> Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS
>>> mode.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> cfe/trunk/include/clang/Lex/TokenLexer.h
>>> cfe/trunk/lib/Lex/PPLexerChange.cpp
>>> cfe/trunk/lib/Lex/TokenLexer.cpp
>>> cfe/trunk/test/Preprocessor/macro_paste_msextensions.c
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256595&r1=256594&r2=256595&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29
>>> 17:06:17 2015
>>> @@ -765,6 +765,7 @@ def MicrosoftCast : DiagGroup<"microsoft
>>>  def MicrosoftConstInit : DiagGroup<"microsoft-const-init">;
>>>  def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
>>>  def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
>>> +def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
>>>  // Aliases.
>>>  def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
>>>  // -Wmsvc-include = -Wmicrosoft-include
>>> @@ -778,7 +779,8 @@ def Microsoft : DiagGroup<"microsoft",
>>>   MicrosoftEnumValue, MicrosoftDefaultArgRedefinition,
>>> MicrosoftTemplate,
>>>   MicrosoftRedeclareStatic, MicrosoftEnumForwardReference,
>>> MicrosoftGoto,
>>>   MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
>>> - MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>;
>>> + MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
>>> + MicrosoftCommentPaste]>;
>>>
>>>  def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256595&r1=256594&r2=256595&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29
>>> 17:06:17 2015
>>> @@ -59,6 +59,9 @@ def ext_dollar_in_identifier : Extension
>>>  def ext_charize_microsoft : Extension<
>>>"charizing operator #@ is a Microsoft extension">,
>>>InGroup;
>>> +def ext_comment_paste_microsoft : Extension<
>>> +  "pasting two '/' tokens into a '//' comment token is a Microsoft
>>> extension">,
>>>
>>
>> It's not really technically correct to call this a token. Maybe drop the
>> word "token" here?
>>
>
> Thanks for the review! You mean only the second "token", not the first
> "tokens", right?
>

Yes.

And FWIW I find this extension horrifying. =)

+  InGroup;
>>>
>>>  def ext_token_used : Extension<"extension used">,
>>>InGroup>;
>>>
>>> Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=256595&r1=256594&r2=256595&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
>>> +++ cfe/trunk/include/clang/Lex/TokenLexer.h Tue Dec 29 17:06:17 2015
>>> @@ -175,7 +175,7 @@ private:
>>>/// macro, other active macros, and anything left on the current
>>> physical
>>>/// source line of the expanded buffer.  Handle this by returning the
>>>/// first token on the next line.
>>> -  void HandleMicrosoftCommentPaste(Token &Tok);
>>> +  void HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc);
>>>
>>>/// \brief If \p loc is a FileID and points inside the current macro
>>>/// definition, returns the appropriate source location pointing at
>>> the
>>>
>>> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=256595&r1=256594&r2=256595&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
>>> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Dec 29 17:06:17 2015
>>> @@ -561,7 +561,6 @@ void Preprocessor::RemoveTopOfLexerStack
>>>  void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
>>>assert(CurTokenLexer && !CurPPLexer &&
>>>   "Pasted co

r256600 - Address review comment on r256595

2015-12-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Dec 29 17:30:42 2015
New Revision: 256600

URL: http://llvm.org/viewvc/llvm-project?rev=256600&view=rev
Log:
Address review comment on r256595

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256600&r1=256599&r2=256600&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29 17:30:42 2015
@@ -60,7 +60,7 @@ def ext_charize_microsoft : Extension<
   "charizing operator #@ is a Microsoft extension">,
   InGroup;
 def ext_comment_paste_microsoft : Extension<
-  "pasting two '/' tokens into a '//' comment token is a Microsoft extension">,
+  "pasting two '/' tokens into a '//' comment is a Microsoft extension">,
   InGroup;
 def ext_ctrl_z_eof_microsoft : Extension<
   "treating Ctrl-Z as end-of-file is a Microsoft extension">,


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


Re: r256595 - Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.

2015-12-29 Thread Nico Weber via cfe-commits
On Tue, Dec 29, 2015 at 6:28 PM, Richard Smith 
wrote:

> On Tue, Dec 29, 2015 at 3:23 PM, Nico Weber  wrote:
>
>> On Tue, Dec 29, 2015 at 6:16 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Tue, Dec 29, 2015 at 3:06 PM, Nico Weber via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: nico
 Date: Tue Dec 29 17:06:17 2015
 New Revision: 256595

 URL: http://llvm.org/viewvc/llvm-project?rev=256595&view=rev
 Log:
 Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS
 mode.

 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticGroups.td
 cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
 cfe/trunk/include/clang/Lex/TokenLexer.h
 cfe/trunk/lib/Lex/PPLexerChange.cpp
 cfe/trunk/lib/Lex/TokenLexer.cpp
 cfe/trunk/test/Preprocessor/macro_paste_msextensions.c

 Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256595&r1=256594&r2=256595&view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 29
 17:06:17 2015
 @@ -765,6 +765,7 @@ def MicrosoftCast : DiagGroup<"microsoft
  def MicrosoftConstInit : DiagGroup<"microsoft-const-init">;
  def MicrosoftVoidPseudoDtor : DiagGroup<"microsoft-void-pseudo-dtor">;
  def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
 +def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
  // Aliases.
  def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
  // -Wmsvc-include = -Wmicrosoft-include
 @@ -778,7 +779,8 @@ def Microsoft : DiagGroup<"microsoft",
   MicrosoftEnumValue, MicrosoftDefaultArgRedefinition,
 MicrosoftTemplate,
   MicrosoftRedeclareStatic, MicrosoftEnumForwardReference,
 MicrosoftGoto,
   MicrosoftFlexibleArray, MicrosoftExtraQualification,
 MicrosoftCast,
 - MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag]>;
 + MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
 + MicrosoftCommentPaste]>;

  def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;


 Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=256595&r1=256594&r2=256595&view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 29
 17:06:17 2015
 @@ -59,6 +59,9 @@ def ext_dollar_in_identifier : Extension
  def ext_charize_microsoft : Extension<
"charizing operator #@ is a Microsoft extension">,
InGroup;
 +def ext_comment_paste_microsoft : Extension<
 +  "pasting two '/' tokens into a '//' comment token is a Microsoft
 extension">,

>>>
>>> It's not really technically correct to call this a token. Maybe drop the
>>> word "token" here?
>>>
>>
>> Thanks for the review! You mean only the second "token", not the first
>> "tokens", right?
>>
>
> Yes.
>

Done in 256600.


>
> And FWIW I find this extension horrifying. =)
>
> +  InGroup;

  def ext_token_used : Extension<"extension used">,
InGroup>;

 Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=256595&r1=256594&r2=256595&view=diff

 ==
 --- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
 +++ cfe/trunk/include/clang/Lex/TokenLexer.h Tue Dec 29 17:06:17 2015
 @@ -175,7 +175,7 @@ private:
/// macro, other active macros, and anything left on the current
 physical
/// source line of the expanded buffer.  Handle this by returning the
/// first token on the next line.
 -  void HandleMicrosoftCommentPaste(Token &Tok);
 +  void HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc);

/// \brief If \p loc is a FileID and points inside the current macro
/// definition, returns the appropriate source location pointing at
 the

 Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=256595&r1=256594&r2=256595&view=diff

 ==
 --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
 +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Dec 29 17:06:17 2015
>

Re: [PATCH] D15814: Implicit conversion from float->bool

2015-12-29 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: test/SemaCXX/warn-literal-conversion.cpp:49-50
@@ +48,4 @@
+  // values.
+  bool b3 = 0.0f;
+  bool b4 = 0.0;
+}

What about

  bool b5 = 1.0;
  bool b6 = 2.0;

? Arguably any `float` -> `bool` conversion changes the value (because `true` 
and `false` are not values of type `float`), so it wouldn't be completely 
unreasonable to warn even if the literal is `0.0`.


http://reviews.llvm.org/D15814



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


r256601 - Model NamespaceAliasDecls as having their nominated namespace as an underlying

2015-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 29 17:34:32 2015
New Revision: 256601

URL: http://llvm.org/viewvc/llvm-project?rev=256601&view=rev
Log:
Model NamespaceAliasDecls as having their nominated namespace as an underlying
declaration. This fixes an issue where we would reject (due to a claimed
ambiguity) a case where lookup finds multiple NamespaceAliasDecls from
different scopes that nominate the same namespace.

The C++ standard doesn't make it clear that such a case is in fact valid (which
I'm working on fixing), but there are no relevant rules that distinguish using
declarations and namespace alias declarations here, so it makes sense to treat
them the same way.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/namespace-alias.cpp
cfe/trunk/test/SemaCXX/using-decl-1.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256601&r1=256600&r2=256601&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 29 17:34:32 2015
@@ -319,7 +319,8 @@ public:
   NamedDecl *getUnderlyingDecl() {
 // Fast-path the common case.
 if (this->getKind() != UsingShadow &&
-this->getKind() != ObjCCompatibleAlias)
+this->getKind() != ObjCCompatibleAlias &&
+this->getKind() != NamespaceAlias)
   return this;
 
 return getUnderlyingDeclImpl();

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=256601&r1=256600&r2=256601&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Dec 29 17:34:32 2015
@@ -1607,6 +1607,9 @@ NamedDecl *NamedDecl::getUnderlyingDeclI
   if (auto *AD = dyn_cast(ND))
 return AD->getClassInterface();
 
+  if (auto *AD = dyn_cast(ND))
+return AD->getNamespace();
+
   return ND;
 }
 

Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=256601&r1=256600&r2=256601&view=diff
==
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Tue Dec 29 17:34:32 2015
@@ -291,8 +291,10 @@ bool Sema::isAcceptableNestedNameSpecifi
   if (!SD)
 return false;
 
+  SD = SD->getUnderlyingDecl();
+
   // Namespace and namespace aliases are fine.
-  if (isa(SD) || isa(SD))
+  if (isa(SD))
 return true;
 
   if (!isa(SD))
@@ -396,10 +398,7 @@ bool Sema::isNonTypeNestedNameSpecifier(
   }
   Found.suppressDiagnostics();
   
-  if (NamedDecl *ND = Found.getAsSingle())
-return isa(ND) || isa(ND);
-  
-  return false;
+  return Found.getAsSingle();
 }
 
 namespace {
@@ -615,7 +614,8 @@ bool Sema::BuildCXXNestedNameSpecifier(S
 }
   }
 
-  NamedDecl *SD = Found.getAsSingle();
+  NamedDecl *SD =
+  Found.isSingleResult() ? Found.getRepresentativeDecl() : nullptr;
   bool IsExtension = false;
   bool AcceptSpec = isAcceptableNestedNameSpecifier(SD, &IsExtension);
   if (!AcceptSpec && IsExtension) {
@@ -687,7 +687,8 @@ bool Sema::BuildCXXNestedNameSpecifier(S
   return false;
 }
 
-QualType T = Context.getTypeDeclType(cast(SD));
+QualType T =
+Context.getTypeDeclType(cast(SD->getUnderlyingDecl()));
 TypeLocBuilder TLB;
 if (isa(T)) {
   InjectedClassNameTypeLoc InjectedTL

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=256601&r1=256600&r2=256601&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Dec 29 17:34:32 2015
@@ -494,6 +494,7 @@ bool ResultBuilder::isInterestingDecl(co
   bool &AsNestedNameSpecifier) const {
   AsNestedNameSpecifier = false;
 
+  auto *Named = ND;
   ND = ND->getUnderlyingDecl();
 
   // Skip unnamed entities.
@@ -526,14 +527,14 @@ bool ResultBuilder::isInterestingDecl(co
 return false;
 
   if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
-  ((isa(ND) || isa(ND)) &&
+  (isa(ND) &&
Filter != &ResultBuilder::IsNamespace &&
Filter != &ResultBuilder::IsNamespaceOrAlias &&
Filter != nullptr))
 AsNestedNameSpecifier = true;
 
   // Filter out any unwanted results.
-  if (Filter && !(this->*Filter)(ND)) {
+  if (Filter && !(this->*Filter)(Named)) {
 // Check whether it is interesting as a nested-name-specifier.
 if (AllowNestedNameSpecifiers && SemaRef.getLa

r256602 - When a namespace alias redeclares a using declaration, point the diagnostic at

2015-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 29 17:42:34 2015
New Revision: 256602

URL: http://llvm.org/viewvc/llvm-project?rev=256602&view=rev
Log:
When a namespace alias redeclares a using declaration, point the diagnostic at
the using declaration not at the thing it's using.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/namespace-alias.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=256602&r1=256601&r2=256602&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec 29 17:42:34 2015
@@ -8688,9 +8688,9 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope
 
   // Find the previous declaration and check that we can redeclare it.
   NamespaceAliasDecl *Prev = nullptr; 
-  if (NamedDecl *PrevDecl = PrevR.getAsSingle()) {
-if (NamespaceAliasDecl *AD =
-dyn_cast(PrevR.getRepresentativeDecl())) {
+  if (PrevR.isSingleResult()) {
+NamedDecl *PrevDecl = PrevR.getRepresentativeDecl();
+if (NamespaceAliasDecl *AD = dyn_cast(PrevDecl)) {
   // We already have an alias with the same name that points to the same
   // namespace; check that it matches.
   if (AD->getNamespace()->Equals(getNamespaceDecl(ND))) {
@@ -8703,7 +8703,7 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope
 return nullptr;
   }
 } else if (isVisible(PrevDecl)) {
-  unsigned DiagID = isa(PrevDecl)
+  unsigned DiagID = isa(PrevDecl->getUnderlyingDecl())
 ? diag::err_redefinition
 : diag::err_redefinition_different_kind;
   Diag(AliasLoc, DiagID) << Alias;

Modified: cfe/trunk/test/SemaCXX/namespace-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/namespace-alias.cpp?rev=256602&r1=256601&r2=256602&view=diff
==
--- cfe/trunk/test/SemaCXX/namespace-alias.cpp (original)
+++ cfe/trunk/test/SemaCXX/namespace-alias.cpp Tue Dec 29 17:42:34 2015
@@ -157,3 +157,14 @@ namespace MultipleUnambiguousLookupResul
   int x2 = X::x; // ok, unambiguous
   int y2 = Y::y; // ok, unambiguous
 }
+
+namespace RedeclOfNonNamespace {
+  int a; // expected-note {{previous}}
+  namespace X { int b; }
+  using X::b; // expected-note {{previous}}
+  namespace c {} // expected-note {{previous}}
+
+  namespace a = X; // expected-error {{different kind}}
+  namespace b = X; // expected-error {{different kind}}
+  namespace c = X; // expected-error-re {{redefinition of 'c'{{$
+}


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


r256603 - [analyzer] Suppress nullability warning for _Nonnull locals zero-initialized by ObjC ARC.

2015-12-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Dec 29 17:44:19 2015
New Revision: 256603

URL: http://llvm.org/viewvc/llvm-project?rev=256603&view=rev
Log:
[analyzer] Suppress nullability warning for _Nonnull locals zero-initialized by 
ObjC ARC.

Prevent the analyzer from warning when a _Nonnnull local variable is implicitly
zero-initialized because of Objective-C automated reference counting. This 
avoids false
positives in cases where a _Nonnull local variable cannot be initialized with an
initialization expression, such as:
  NSString * _Nonnull s; // no-warning
  @autoreleasepool {
s = ...;
  }

The nullability checker will still warn when a _Nonnull local variable is 
explicitly
initialized with nil.

This suppression introduces the potential for false negatives if the local 
variable
is used before it is assigned a _Nonnull value. Based on a discussion with Anna 
Zaks,
Jordan Rose, and John McCall, I've added a FIXME to treat implicitly 
zero-initialized
_Nonnull locals as uninitialized in Sema's UninitializedValues analysis to 
avoid these
false negatives.

rdar://problem/23522311

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=256603&r1=256602&r2=256603&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Tue Dec 29 
17:44:19 2015
@@ -897,6 +897,48 @@ static const Expr * matchValueExprForBin
   return nullptr;
 }
 
+/// Returns true if \param S is a DeclStmt for a local variable that
+/// ObjC automated reference counting initialized with zero.
+static bool isARCNilInitializedLocal(CheckerContext &C, const Stmt *S) {
+  // We suppress diagnostics for ARC zero-initialized _Nonnull locals. This
+  // prevents false positives when a _Nonnull local variable cannot be
+  // initialized with an initialization expression:
+  //NSString * _Nonnull s; // no-warning
+  //@autoreleasepool {
+  //  s = ...
+  //}
+  //
+  // FIXME: We should treat implicitly zero-initialized _Nonnull locals as
+  // uninitialized in Sema's UninitializedValues analysis to warn when a use of
+  // the zero-initialized definition will unexpectedly yield nil.
+
+  // Locals are only zero-initialized when automated reference counting
+  // is turned on.
+  if (!C.getASTContext().getLangOpts().ObjCAutoRefCount)
+return false;
+
+  auto *DS = dyn_cast(S);
+  if (!DS || !DS->isSingleDecl())
+return false;
+
+  auto *VD = dyn_cast(DS->getSingleDecl());
+  if (!VD)
+return false;
+
+  // Sema only zero-initializes locals with ObjCLifetimes.
+  if(!VD->getType().getQualifiers().hasObjCLifetime())
+return false;
+
+  const Expr *Init = VD->getInit();
+  assert(Init && "ObjC local under ARC without initializer");
+
+  // Return false if the local is explicitly initialized (e.g., with '= nil').
+  if (!isa(Init))
+return false;
+
+  return true;
+}
+
 /// Propagate the nullability information through binds and warn when nullable
 /// pointer or null symbol is assigned to a pointer with a nonnull type.
 void NullabilityChecker::checkBind(SVal L, SVal V, const Stmt *S,
@@ -928,7 +970,8 @@ void NullabilityChecker::checkBind(SVal
   if (Filter.CheckNullPassedToNonnull &&
   RhsNullness == NullConstraint::IsNull &&
   ValNullability != Nullability::Nonnull &&
-  LocNullability == Nullability::Nonnull) {
+  LocNullability == Nullability::Nonnull &&
+  !isARCNilInitializedLocal(C, S)) {
 static CheckerProgramPointTag Tag(this, "NullPassedToNonnull");
 ExplodedNode *N = C.generateErrorNode(State, &Tag);
 if (!N)

Modified: cfe/trunk/test/Analysis/nullability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.mm?rev=256603&r1=256602&r2=256603&view=diff
==
--- cfe/trunk/test/Analysis/nullability.mm (original)
+++ cfe/trunk/test/Analysis/nullability.mm Tue Dec 29 17:44:19 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,nullability -verify %s
+// RUN: %clang_cc1 -fobjc-arc -analyze -analyzer-checker=core,nullability 
-verify %s
 
 #define nil 0
 #define BOOL int
@@ -278,3 +278,12 @@ Dummy *_Nonnull testDefensiveInlineCheck
 
   return p;
 }
+
+void testObjCARCImplicitZeroInitialization() {
+  TestObject * _Nonnull implicitlyZeroInitialized; // no-warning
+  implicitlyZeroInitialized = getNonnullTestObject();
+}
+
+void testObjCARCExplicitZeroInitialization() {
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{Null is assigned to a pointer which is expected to have non-null value}}
+}



Re: [PATCH] D15813: [libcxx] Refactoring target_info.py used by lit tests

2015-12-29 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

This is NOT correct and it's breaking bots.  I don't want to revert it because 
I really like the change but it needs to be fixed quickly.

@bcraig You removed the logic that tests if a system provides a given locale. 
We use this information to enable/disable tests. Please add it back.
I put an inline comment next to the original logic.

Example Breakage: 
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-arm-linux/builds/780



Comment at: test/libcxx/test/config.py:302
@@ -301,3 +242,1 @@
 
-if target_system in locales:
-default_locale = locale.setlocale(locale.LC_ALL)

This test is important!


http://reviews.llvm.org/D15813



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


r256605 - [analyzer] Handle another Android assert function.

2015-12-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Dec 29 18:08:59 2015
New Revision: 256605

URL: http://llvm.org/viewvc/llvm-project?rev=256605&view=rev
Log:
[analyzer] Handle another Android assert function.

Android's assert can call both the __assert and __assert2 functions under the 
cover, but
the NoReturnFunctionChecker does not handle the latter. This commit fixes that.

A patch by Yury Gribov!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/test/Analysis/NoReturn.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp?rev=256605&r1=256604&r2=256605&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp Tue Dec 
29 18:08:59 2015
@@ -66,6 +66,7 @@ void NoReturnFunctionChecker::checkPostC
 .Case("assfail", true)
 .Case("db_error", true)
 .Case("__assert", true)
+.Case("__assert2", true)
 // For the purpose of static analysis, we do not care that
 //  this MSVC function will return if the user decides to continue.
 .Case("_wassert", true)

Modified: cfe/trunk/test/Analysis/NoReturn.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NoReturn.m?rev=256605&r1=256604&r2=256605&view=diff
==
--- cfe/trunk/test/Analysis/NoReturn.m (original)
+++ cfe/trunk/test/Analysis/NoReturn.m Tue Dec 29 18:08:59 2015
@@ -131,3 +131,15 @@ void test_wassert() {
   int *p = 0;
   *p = 0xDEADBEEF; // no-warning
 }
+#undef assert
+
+// Test that hard-coded Android __assert2 name is recognized as a noreturn
+#define assert(_Expression) ((_Expression) ? (void)0 : __assert2(0, 0, 0, 0));
+extern void __assert2(const char *, int, const char *, const char *);
+extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
+void test___assert2() {
+  assert(0);
+  int *p = 0;
+  *p = 0xDEADBEEF; // no-warning
+}
+#undef assert


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


Buildbot numbers for week of 12/20/2015 - 12/26/2015

2015-12-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 12/20/2015 -
12/26/2015.

Thanks

Galina



Number of commits by project:

 project   |   commits
---+---
 llvm  |   150
 cfe   |53
 lld   |51
 polly |17
 lldb  |15
 compiler-rt   |10
 clang-tools-extra | 6
 libcxxabi | 3
 libcxx| 1
 openmp| 1
---
   307


Number of completed builds, failed builds and average build time for
successful builds per active builder:

 buildername   | completed  |
failed | time
---+++
 clang-aarch64-lnt | 55
|  3 | 02:27:12
 clang-atom-d525-fedora| 17
|| 08:45:17
 clang-atom-d525-fedora-rel| 77
|  4 | 01:21:12
 clang-bpf-build   |171
| 11 | 00:02:52
 clang-cmake-aarch64-42vma |182
|  9 | 00:16:23
 clang-cmake-aarch64-full  | 40
|  2 | 03:35:00
 clang-cmake-aarch64-quick |134
|  8 | 00:24:48
 clang-cmake-armv7-a15 |132
|  8 | 00:25:54
 clang-cmake-armv7-a15-full|  1
|| 03:35:26
 clang-cmake-armv7-a15-selfhost| 38
|  2 | 03:51:57
 clang-cmake-armv7-a15-selfhost-neon   | 29
|  1 | 05:00:51
 clang-cmake-mips  |101
|  4 | 01:10:35
 clang-cmake-mipsel| 31
|  1 | 04:27:44
 clang-cmake-thumbv7-a15   |136
| 10 | 00:22:08
 clang-cmake-thumbv7-a15-full-sh   | 26
|| 05:41:41
 clang-hexagon-elf |153
| 10 | 00:13:31
 clang-native-aarch64-full | 10
|| 07:50:17
 clang-native-arm-lnt  | 89
|  3 | 01:00:15
 clang-native-arm-lnt-perf | 15
|| 09:24:33
 clang-ppc64-elf-linux | 81
|  8 | 01:08:57
 clang-ppc64-elf-linux2|133
|  8 | 00:26:01
 clang-sphinx-docs | 51
|| 00:00:22
 clang-x64-ninja-win7  |119
| 67 | 00:35:14
 clang-x86-win2008-selfhost| 85
| 14 | 01:11:17
 clang-x86_64-darwin13-cross-arm   |143
|  2 | 00:19:04
 clang-x86_64-darwin13-cross-mingw32   |138
|  4 | 00:22:30
 clang-x86_64-debian-fast  | 75
|  5 | 00:10:48
 clang-x86_64-linux-abi-test   |171
|  7 | 00:09:40
 clang-x86_64-linux-selfhost-modules   |152
| 10 | 00:15:42
 clang-x86_64-ubuntu-gdb-75|103
|  7 | 00:42:15
 libcxx-libcxxabi-arm-linux|  4
|| 01:07:37
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian   |  1
|| 00:09:34
 libcxx-libcxxabi-x86_64-linux-debian  |  1
|| 00:09:36
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions |  1
|| 00:09:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan |  4
|  1 | 00:10:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03|  4
|| 00:04:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11|  4
|| 00:05:38
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14|  4
|| 00:05:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z|  4
|| 00:05:55
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan |  4
|  1 | 00:21:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan |  4
|  1 | 00:14:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-unstable-abi | 

[libcxx] r256606 - Cleanup CMake for out-of-tree builds

2015-12-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 29 19:02:38 2015
New Revision: 256606

URL: http://llvm.org/viewvc/llvm-project?rev=256606&view=rev
Log:
Cleanup CMake for out-of-tree builds

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=256606&r1=256605&r2=256606&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Dec 29 19:02:38 2015
@@ -12,20 +12,29 @@ if(POLICY CMP0022)
   cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
 endif()
 
-project(libcxx CXX C)
-
-set(PACKAGE_NAME libcxx)
-set(PACKAGE_VERSION trunk-svn)
-set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
-
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
-  ${CMAKE_MODULE_PATH}
+   ${CMAKE_MODULE_PATH}
   )
 
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(libcxx CXX C)
+  set(PACKAGE_NAME libcxx)
+  set(PACKAGE_VERSION trunk-svn)
+  set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+  set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
+
+  # Configure for a standalone build
+  message(STATUS "Configuring for standalone build.")
+  set(LIBCXX_BUILT_STANDALONE 1)
+
+  # Find the LLVM sources and simulate LLVM CMake options.
+  include(HandleOutOfTreeLLVM)
+  handle_out_of_tree_llvm()
+endif()
+
 # Require out of source build.
 include(MacroEnsureOutOfSourceBuild)
 MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
@@ -33,15 +42,6 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
  build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
  )
 
-# Find the LLVM sources and simulate LLVM CMake options.
-include(HandleOutOfTreeLLVM)
-if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND)
-  message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
-  "llvm-config not found and LLVM_PATH not defined.\n"
-  "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
-  "or -DLLVM_PATH=path/to/llvm-source-root.")
-endif()
-
 
#===
 # Setup CMake Options
 
#===

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=256606&r1=256605&r2=256606&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Tue Dec 29 19:02:38 
2015
@@ -1,4 +1,6 @@
-macro(find_llvm_parts)
+
+
+macro(internal_find_llvm_parts)
 # Rely on llvm-config.
   set(CONFIG_OUTPUT)
   find_program(LLVM_CONFIG "llvm-config")
@@ -57,16 +59,13 @@ macro(find_llvm_parts)
   list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
 
   set(LLVM_FOUND ON)
-endmacro(find_llvm_parts)
-
+endmacro(internal_find_llvm_parts)
 
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-  set(LIBCXX_BUILT_STANDALONE 1)
-  message(STATUS "Configuring for standalone build.")
-
-  find_llvm_parts()
 
+macro(internal_simulate_llvm_options)
   # LLVM Options --
+  # Configure the LLVM CMake options expected by libc++.
+
   include(FindPythonInterp)
   if( NOT PYTHONINTERP_FOUND )
 message(WARNING "Failed to find python interpreter. "
@@ -132,7 +131,29 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   MESSAGE(SEND_ERROR "Unable to determine platform")
 endif(UNIX)
   endif(WIN32)
+endmacro(internal_simulate_llvm_options)
+
+
+macro(handle_out_of_tree_llvm)
+  # This macro should not be called unless we are building out of tree.
+  # Enforce that.
+  if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+message(FATAL_ERROR "libc++ incorrectly configured for out-of-tree LLVM")
+  endif()
+
+  # Attempt to find an LLVM installation and source directory. Warn if they
+  # are not found.
+  internal_find_llvm_parts()
+  if (NOT LLVM_FOUND)
+message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
+"llvm-config not found and LLVM_PATH not defined.\n"
+"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
+"or -DLLVM_PATH=path/to/llvm-source-root.")
+  endif()
+
+  # Simulate the LLVM CMake options and variables provided by an in-tree LLVM.
+  internal_simulate_llvm_options()
 
-  # Add LLVM Functions 
+  # Additionally include the LLVM CMake functions if we can find the module.
   include(AddLLVM OPTIONAL)
-endif(

r256607 - Clean up this code, NFC.

2015-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 29 19:06:52 2015
New Revision: 256607

URL: http://llvm.org/viewvc/llvm-project?rev=256607&view=rev
Log:
Clean up this code, NFC.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=256607&r1=256606&r2=256607&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Dec 29 19:06:52 2015
@@ -7305,20 +7305,24 @@ void CheckImplicitConversion(Sema &S, Ex
   }
 }
 
-// If the target is bool, warn if expr is a function or method call.
-if (Target->isSpecificBuiltinType(BuiltinType::Bool) &&
-isa(E)) {
+// Detect the case where a call result is converted from floating-point to
+// to bool, and the final argument to the call is converted from bool, to
+// discover this typo:
+//
+//bool b = fabs(x < 1.0);  // should be "bool b = fabs(x) < 1.0;"
+//
+// FIXME: This is an incredibly special case; is there some more general
+// way to detect this class of misplaced-parentheses bug?
+if (Target->isBooleanType() && isa(E)) {
   // Check last argument of function call to see if it is an
   // implicit cast from a type matching the type the result
   // is being cast to.
   CallExpr *CEx = cast(E);
-  unsigned NumArgs = CEx->getNumArgs();
-  if (NumArgs > 0) {
+  if (unsigned NumArgs = CEx->getNumArgs()) {
 Expr *LastA = CEx->getArg(NumArgs - 1);
 Expr *InnerE = LastA->IgnoreParenImpCasts();
-const Type *InnerType =
-  S.Context.getCanonicalType(InnerE->getType()).getTypePtr();
-if (isa(LastA) && (InnerType == Target)) {
+if (isa(LastA) &&
+InnerE->getType()->isBooleanType()) {
   // Warn on this floating-point to bool conversion
   DiagnoseImpCast(S, E, T, CC,
   diag::warn_impcast_floating_point_to_bool);


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


r256608 - [TrailingObjects] Convert CastExpr and subclasses.

2015-12-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Dec 29 20:27:28 2015
New Revision: 256608

URL: http://llvm.org/viewvc/llvm-project?rev=256608&view=rev
Log:
[TrailingObjects] Convert CastExpr and subclasses.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=256608&r1=256607&r2=256608&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Dec 29 20:27:28 2015
@@ -2678,8 +2678,6 @@ public:
   path_const_iterator path_begin() const { return path_buffer(); }
   path_const_iterator path_end() const { return path_buffer() + path_size(); }
 
-  void setCastPath(const CXXCastPath &Path);
-
   static bool classof(const Stmt *T) {
 return T->getStmtClass() >= firstCastExprConstant &&
T->getStmtClass() <= lastCastExprConstant;
@@ -2709,7 +2707,9 @@ public:
 /// // to an xvalue of type Base
 /// }
 /// @endcode
-class ImplicitCastExpr : public CastExpr {
+class ImplicitCastExpr final
+: public CastExpr,
+  private llvm::TrailingObjects {
 private:
   ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
unsigned BasePathLength, ExprValueKind VK)
@@ -2745,6 +2745,9 @@ public:
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == ImplicitCastExprClass;
   }
+
+  friend TrailingObjects;
+  friend class CastExpr;
 };
 
 inline Expr *Expr::IgnoreImpCasts() {
@@ -2804,7 +2807,9 @@ public:
 /// CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style
 /// cast in C++ (C++ [expr.cast]), which uses the syntax
 /// (Type)expr. For example: @c (int)f.
-class CStyleCastExpr : public ExplicitCastExpr {
+class CStyleCastExpr final
+: public ExplicitCastExpr,
+  private llvm::TrailingObjects {
   SourceLocation LPLoc; // the location of the left paren
   SourceLocation RPLoc; // the location of the right paren
 
@@ -2842,6 +2847,9 @@ public:
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CStyleCastExprClass;
   }
+
+  friend TrailingObjects;
+  friend class CastExpr;
 };
 
 /// \brief A builtin binary operation expression such as "x + y" or "x <= y".

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=256608&r1=256607&r2=256608&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Dec 29 20:27:28 2015
@@ -235,7 +235,9 @@ public:
 ///
 /// This expression node represents a C++ static cast, e.g.,
 /// \c static_cast(1.0).
-class CXXStaticCastExpr : public CXXNamedCastExpr {
+class CXXStaticCastExpr final
+: public CXXNamedCastExpr,
+  private llvm::TrailingObjects {
   CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
 unsigned pathSize, TypeSourceInfo *writtenTy,
 SourceLocation l, SourceLocation RParenLoc,
@@ -259,6 +261,9 @@ public:
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXStaticCastExprClass;
   }
+
+  friend TrailingObjects;
+  friend class CastExpr;
 };
 
 /// \brief A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
@@ -266,7 +271,9 @@ public:
 /// This expression node represents a dynamic cast, e.g.,
 /// \c dynamic_cast(BasePtr). Such a cast may perform a run-time
 /// check to determine how to perform the type conversion.
-class CXXDynamicCastExpr : public CXXNamedCastExpr {
+class CXXDynamicCastExpr final
+: public CXXNamedCastExpr,
+  private llvm::TrailingObjects {
   CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
  Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
  SourceLocation l, SourceLocation RParenLoc,
@@ -293,6 +300,9 @@ public:
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDynamicCastExprClass;
   }
+
+  friend TrailingObjects;
+  friend class CastExpr;
 };
 
 /// \brief A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
@@ -303,7 +313,10 @@ public:
 /// A reinterpret_cast provides a differently-typed view of a value but
 /// (in Clang, as in most C++ implementations) performs no actual work at
 /// run time.
-class CXXReinterpretCastExpr : public CXXNamedCastExpr {
+class CXXReinterpretCastExpr final
+: public CXXNamedCastExpr,
+  private llvm::TrailingObjects {
   CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
  Expr *op, unsigned pathSize,
  TypeSourceInfo *writtenTy, SourceLocation l,
@@ -328

r256609 - [ptr-traits] Stop using two bogus types as stand-ins for flags

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 20:51:00 2015
New Revision: 256609

URL: http://llvm.org/viewvc/llvm-project?rev=256609&view=rev
Log:
[ptr-traits] Stop using two bogus types as stand-ins for flags
indicating the nature of the default argument in a ParmVarDecl.

Instead, this adds a proper enum stored exclusively in the ParmVarDecl
bits (which we have plenty of) for this. This even allows us to track
a previously unrepresented state in Clang when we parse a function
declaration with a default argument on a parameter but we cannot even
form an invalid expression node (for example, it is an invalid token).
Now, we can model this state in the AST at least, and potentially
improve recovery in this area in the future.

I've also cleaned up the functions managing both variable initializer
expressions and parameter default argument expresssions as much as
possible. I've left some comments about further improvements based on
a discussion with Richard Smith. Lots of credit to him for walking me
through exactly which of the *many* tradeoffs here he felt was the best
fit.

Should be NFC for now. I've tried my best to preserve existing behavior.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

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

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256609&r1=256608&r2=256609&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 29 20:51:00 2015
@@ -729,17 +729,14 @@ public:
   };
 
 protected:
-  /// \brief Placeholder type used in Init to denote an unparsed C++ default
-  /// argument.
-  struct UnparsedDefaultArgument;
-
-  /// \brief Placeholder type used in Init to denote an uninstantiated C++
-  /// default argument.
-  struct UninstantiatedDefaultArgument;
-
-  typedef llvm::PointerUnion4 InitType;
+  // A pointer union of Stmt * and EvaluatedStmt *. When an EvaluatedStmt, we
+  // have allocated the auxilliary struct of information there.
+  //
+  // TODO: It is a bit unfortunate to use a PointerUnion inside the VarDecl for
+  // this as *many* VarDecls are ParmVarDecls that don't have default
+  // arguments. We could save some space by moving this pointer union to be
+  // allocated in trailing space when necessary.
+  typedef llvm::PointerUnion InitType;
 
   /// \brief The initializer for this variable or, for a ParmVarDecl, the
   /// C++ default argument.
@@ -763,6 +760,13 @@ private:
 protected:
   enum { NumParameterIndexBits = 8 };
 
+  enum DefaultArgKind {
+DAK_None,
+DAK_Unparsed,
+DAK_Uninstantiated,
+DAK_Normal
+  };
+
   class ParmVarDeclBitfields {
 friend class ParmVarDecl;
 friend class ASTDeclReader;
@@ -773,6 +777,12 @@ protected:
 /// prior declaration.
 unsigned HasInheritedDefaultArg : 1;
 
+/// Describes the kind of default argument for this parameter. By default
+/// this is none. If this is normal, then the default argument is stored in
+/// the \c VarDecl initalizer expression unless we were unble to parse
+/// (even an invalid) expression for the default argument.
+unsigned DefaultArgKind : 2;
+
 /// Whether this parameter undergoes K&R argument promotion.
 unsigned IsKNRPromoted : 1;
 
@@ -1066,47 +1076,14 @@ public:
   /// declaration it is attached to. Also get that declaration.
   const Expr *getAnyInitializer(const VarDecl *&D) const;
 
-  bool hasInit() const {
-return !Init.isNull() && (Init.is() || Init.is());
-  }
+  bool hasInit() const;
   const Expr *getInit() const {
-if (Init.isNull())
-  return nullptr;
-
-const Stmt *S = Init.dyn_cast();
-if (!S) {
-  if (EvaluatedStmt *ES = Init.dyn_cast())
-S = ES->Value;
-}
-return (const Expr*) S;
-  }
-  Expr *getInit() {
-if (Init.isNull())
-  return nullptr;
-
-Stmt *S = Init.dyn_cast();
-if (!S) {
-  if (EvaluatedStmt *ES = Init.dyn_cast())
-S = ES->Value;
-}
-
-return (Expr*) S;
+return const_cast(this)->getInit();
   }
+  Expr *getInit();
 
   /// \brief Retrieve the address of the initializer expression.
-  Stmt **getInitAddress() {
-if (EvaluatedStmt *ES = Init.dyn_cast())
-  return &ES->Value;
-
-// This union hack tip-toes around strict-aliasing rules.
-union {
-  InitType *InitPtr;
-  Stmt **StmtPtr;
-};
-
-InitPtr = &Init;
-return StmtPtr;
-  }
+  Stmt **getInitAddress();
 
   void setInit(Expr *I);
 
@@ -1128,33 +1105,18 @@ public:
   /// \brief Return the already-evaluated value of this variable's
   /// initializer, or NULL 

r256610 - [ptr-traits] Switch from a really wasteful SmallDenseMap of

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 21:00:23 2015
New Revision: 256610

URL: http://llvm.org/viewvc/llvm-project?rev=256610&view=rev
Log:
[ptr-traits] Switch from a really wasteful SmallDenseMap of
SmallVector<.., 16> (16) objects to a simple SmallVector of pairs.

This no longer de-duplicates the common function pointers used during
deallocation, but this doesn't really seem worth the complexity and
overhead of managing the map-of-vectors. Notably, there is no reason to
assume that functions have the 4-byte alignment that DenseMap relies on,
and indeed this prevents checking the alignment of the DenseMap keys
because we can't even meaningfully query the alignment of functions
using our existing alignment tools.

Generally, function pointers don't seem like a great idea for keys in
a DenseMap. =]

I chatted with Richard Smith about this a bit as well and have written
down a FIXME because this *does* waste some memory and in general seems
a very clumsy memory management strategy. He would like to see a more
fundamental fix eventually here that tries to build a better pattern.

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

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=256610&r1=256609&r2=256610&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Dec 29 21:00:23 2015
@@ -2514,9 +2514,15 @@ private:
 
   /// \brief A set of deallocations that should be performed when the
   /// ASTContext is destroyed.
-  typedef llvm::SmallDenseMap >
-DeallocationMap;
-  DeallocationMap Deallocations;
+  // FIXME: We really should have a better mechanism in the ASTContext to
+  // manage running destructors for types which do variable sized allocation
+  // within the AST. In some places we thread the AST bump pointer allocator
+  // into the datastructures which avoids this mess during deallocation but is
+  // wasteful of memory, and here we require a lot of error prone book keeping
+  // in order to track and run destructors while we're tearing things down.
+  typedef llvm::SmallVector, 16>
+  DeallocationFunctionsAndArguments;
+  DeallocationFunctionsAndArguments Deallocations;
 
   // FIXME: This currently contains the set of StoredDeclMaps used
   // by DeclContext objects.  This probably should not be in ASTContext,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=256610&r1=256609&r2=256610&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Dec 29 21:00:23 2015
@@ -760,10 +760,8 @@ ASTContext::~ASTContext() {
   ReleaseDeclContextMaps();
 
   // Call all of the deallocation functions on all of their targets.
-  for (DeallocationMap::const_iterator I = Deallocations.begin(),
-   E = Deallocations.end(); I != E; ++I)
-for (unsigned J = 0, N = I->second.size(); J != N; ++J)
-  (I->first)((I->second)[J]);
+  for (auto &Pair : Deallocations)
+(Pair.first)(Pair.second);
 
   // ASTRecordLayout objects in ASTRecordLayouts must always be destroyed
   // because they can contain DenseMaps.
@@ -812,7 +810,7 @@ void ASTContext::ReleaseParentMapEntries
 }
 
 void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {
-  Deallocations[Callback].push_back(Data);
+  Deallocations.push_back({Callback, Data});
 }
 
 void


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


r256611 - [ptr-traits] Switch the Redeclarable template to using a void pointer in

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 21:09:25 2015
New Revision: 256611

URL: http://llvm.org/viewvc/llvm-project?rev=256611&view=rev
Log:
[ptr-traits] Switch the Redeclarable template to using a void pointer in
its PointerUnion rather than an ASTContext pointer.

Using pointers with PointerUnion really should be checking the pointee
type's alignment, and we can't do this without the complete type. The
Redeclarable template inherently can't know the complete type of
ASTContext because of its layering, and because it is a template its
methods can't reasonably be out-of-line the way we traditionally solve
circular references within the AST library.

After discussing this with Richard Smith, his suggestion which I have
implemented here was to just drop to a void* for the PointerUnion. This
essentially documents that we're going to completely ignore the type
(including its potential alignment consequences) for this code. There
are still of course dynamic guards that this ended up working correctly,
and because of the way the code is factored this doesn't leak outside of
the very narrow implementation guts of Redeclarable.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

Modified:
cfe/trunk/include/clang/AST/Redeclarable.h

Modified: cfe/trunk/include/clang/AST/Redeclarable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=256611&r1=256610&r2=256611&view=diff
==
--- cfe/trunk/include/clang/AST/Redeclarable.h (original)
+++ cfe/trunk/include/clang/AST/Redeclarable.h Tue Dec 29 21:09:25 2015
@@ -20,6 +20,7 @@
 #include 
 
 namespace clang {
+class ASTContext;
 
 /// \brief Provides common interface for the Decls that can be redeclared.
 template
@@ -32,7 +33,11 @@ protected:
   &ExternalASTSource::CompleteRedeclChain>
   KnownLatest;
 
-typedef const ASTContext *UninitializedLatest;
+/// We store a pointer to the ASTContext in the UninitializedLatest
+/// pointer, but to avoid circular type dependencies when we steal the low
+/// bits of this pointer, we use a raw void* here.
+typedef const void *UninitializedLatest;
+
 typedef Decl *Previous;
 
 /// A pointer to either an uninitialized latest declaration (where either
@@ -47,7 +52,7 @@ protected:
 enum LatestTag { LatestLink };
 
 DeclLink(LatestTag, const ASTContext &Ctx)
-: Next(NotKnownLatest(&Ctx)) {}
+: Next(NotKnownLatest(reinterpret_cast(&Ctx))) {}
 DeclLink(PreviousTag, decl_type *D)
 : Next(NotKnownLatest(Previous(D))) {}
 
@@ -67,7 +72,8 @@ protected:
   return static_cast(NKL.get());
 
 // Allocate the generational 'most recent' cache now, if needed.
-Next = KnownLatest(*NKL.get(),
+Next = KnownLatest(*reinterpret_cast(
+   NKL.get()),
const_cast(D));
   }
 
@@ -83,7 +89,9 @@ protected:
   assert(NextIsLatest() && "decl became canonical unexpectedly");
   if (Next.is()) {
 NotKnownLatest NKL = Next.get();
-Next = KnownLatest(*NKL.get(), D);
+Next = KnownLatest(*reinterpret_cast(
+   NKL.get()),
+   D);
   } else {
 auto Latest = Next.get();
 Latest.set(D);


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


r256612 - [ptr-traits] Move methods manipulating PointerUnions, DenseMap pointer

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 21:24:14 2015
New Revision: 256612

URL: http://llvm.org/viewvc/llvm-project?rev=256612&view=rev
Log:
[ptr-traits] Move methods manipulating PointerUnions, DenseMap pointer
keys, and PointerIntPairs where the pointee types are incomplete
out-of-line to where we have the complete type.

This is the standard pattern used throughout the AST library to address
the inherently mutually cross referenced nature of the AST.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/TemplateName.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/TemplateName.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=256612&r1=256611&r2=256612&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Dec 29 21:24:14 2015
@@ -2256,9 +2256,7 @@ public:
  const FunctionProtoType *FromFunctionType,
  const FunctionProtoType *ToFunctionType);
 
-  void ResetObjCLayout(const ObjCContainerDecl *CD) {
-ObjCLayouts[CD] = nullptr;
-  }
+  void ResetObjCLayout(const ObjCContainerDecl *CD);
 
   
//======//
   //Integer Predicates
@@ -2309,16 +2307,11 @@ public:
 
   /// \brief Get the duplicate declaration of a ObjCMethod in the same
   /// interface, or null if none exists.
-  const ObjCMethodDecl *getObjCMethodRedeclaration(
-   const ObjCMethodDecl *MD) const 
{
-return ObjCMethodRedecls.lookup(MD);
-  }
+  const ObjCMethodDecl *
+  getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const;
 
   void setObjCMethodRedeclaration(const ObjCMethodDecl *MD,
-  const ObjCMethodDecl *Redecl) {
-assert(!getObjCMethodRedeclaration(MD) && "MD already has a 
redeclaration");
-ObjCMethodRedecls[MD] = Redecl;
-  }
+  const ObjCMethodDecl *Redecl);
 
   /// \brief Returns the Objective-C interface that \p ND belongs to if it is
   /// an Objective-C method/property/ivar etc. that is part of an interface,

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256612&r1=256611&r2=256612&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 29 21:24:14 2015
@@ -464,25 +464,15 @@ public:
   }
 
   /// \brief Get the original (first) namespace declaration.
-  NamespaceDecl *getOriginalNamespace() {
-if (isFirstDecl())
-  return this;
-
-return AnonOrFirstNamespaceAndInline.getPointer();
-  }
+  NamespaceDecl *getOriginalNamespace();
 
   /// \brief Get the original (first) namespace declaration.
-  const NamespaceDecl *getOriginalNamespace() const {
-if (isFirstDecl())
-  return this;
-
-return AnonOrFirstNamespaceAndInline.getPointer();
-  }
+  const NamespaceDecl *getOriginalNamespace() const;
 
   /// \brief Return true if this declaration is an original (first) declaration
   /// of the namespace. This is false for non-original (subsequent) namespace
   /// declarations and anonymous namespaces.
-  bool isOriginalNamespace() const { return isFirstDecl(); }
+  bool isOriginalNamespace() const;
 
   /// \brief Retrieve the anonymous namespace nested inside this namespace,
   /// if any.
@@ -2053,9 +2043,7 @@ public:
   /// \brief If this function is an instantiation of a member function of a
   /// class template specialization, retrieves the member specialization
   /// information.
-  MemberSpecializationInfo *getMemberSpecializationInfo() const {
-return TemplateOrSpecialization.dyn_cast();
-  }
+  MemberSpecializationInfo *getMemberSpecializationInfo() const;
 
   /// \brief Specify that this record is an instantiation of the
   /// member function FD.
@@ -2076,13 +2064,9 @@ public:
   /// FunctionDecl that describes the function template,
   /// getDescribedFunctionTemplate() retrieves the
   /// FunctionTemplateDecl from a FunctionDecl.
-  FunctionTemplateDecl *getDescribedFunctionTemplate() const {
-return TemplateOrSpecialization.dyn_cast();
-  }
+  FunctionTemplateDecl *getDescribedFunctionTemplate() const;
 
-  void setDescribe

r256613 - [ptr-traits] Move a class definition up to the top of this header so it

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 21:33:22 2015
New Revision: 256613

URL: http://llvm.org/viewvc/llvm-project?rev=256613&view=rev
Log:
[ptr-traits] Move a class definition up to the top of this header so it
can be referenced as part of a PointerIntPair.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

Modified:
cfe/trunk/include/clang/Analysis/ProgramPoint.h

Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=256613&r1=256612&r2=256613&view=diff
==
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Tue Dec 29 21:33:22 2015
@@ -33,8 +33,31 @@ namespace clang {
 class AnalysisDeclContext;
 class FunctionDecl;
 class LocationContext;
-class ProgramPointTag;
   
+/// ProgramPoints can be "tagged" as representing points specific to a given
+/// analysis entity.  Tags are abstract annotations, with an associated
+/// description and potentially other information.
+class ProgramPointTag {
+public:
+  ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
+  virtual ~ProgramPointTag();
+  virtual StringRef getTagDescription() const = 0;
+
+protected:
+  /// Used to implement 'isKind' in subclasses.
+  const void *getTagKind() { return TagKind; }
+  
+private:
+  const void *TagKind;
+};
+
+class SimpleProgramPointTag : public ProgramPointTag {
+  std::string Desc;
+public:
+  SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
+  StringRef getTagDescription() const override;
+};
+
 class ProgramPoint {
 public:
   enum Kind { BlockEdgeKind,
@@ -643,30 +666,6 @@ private:
   }
 };
 
-/// ProgramPoints can be "tagged" as representing points specific to a given
-/// analysis entity.  Tags are abstract annotations, with an associated
-/// description and potentially other information.
-class ProgramPointTag {
-public:
-  ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
-  virtual ~ProgramPointTag();
-  virtual StringRef getTagDescription() const = 0;
-
-protected:
-  /// Used to implement 'isKind' in subclasses.
-  const void *getTagKind() { return TagKind; }
-  
-private:
-  const void *TagKind;
-};
-
-class SimpleProgramPointTag : public ProgramPointTag {
-  std::string Desc;
-public:
-  SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
-  StringRef getTagDescription() const override;
-};
-
 } // end namespace clang
 
 


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


[libcxx] r256614 - Revert r256606 due to compiler-rt sanitizer bot failures

2015-12-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 29 21:39:03 2015
New Revision: 256614

URL: http://llvm.org/viewvc/llvm-project?rev=256614&view=rev
Log:
Revert r256606 due to compiler-rt sanitizer bot failures

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=256614&r1=256613&r2=256614&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Dec 29 21:39:03 2015
@@ -12,29 +12,20 @@ if(POLICY CMP0022)
   cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
 endif()
 
+project(libcxx CXX C)
+
+set(PACKAGE_NAME libcxx)
+set(PACKAGE_VERSION trunk-svn)
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
+
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
-   ${CMAKE_MODULE_PATH}
+  ${CMAKE_MODULE_PATH}
   )
 
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-  project(libcxx CXX C)
-  set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION trunk-svn)
-  set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
-  set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
-
-  # Configure for a standalone build
-  message(STATUS "Configuring for standalone build.")
-  set(LIBCXX_BUILT_STANDALONE 1)
-
-  # Find the LLVM sources and simulate LLVM CMake options.
-  include(HandleOutOfTreeLLVM)
-  handle_out_of_tree_llvm()
-endif()
-
 # Require out of source build.
 include(MacroEnsureOutOfSourceBuild)
 MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
@@ -42,6 +33,15 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
  build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
  )
 
+# Find the LLVM sources and simulate LLVM CMake options.
+include(HandleOutOfTreeLLVM)
+if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND)
+  message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
+  "llvm-config not found and LLVM_PATH not defined.\n"
+  "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
+  "or -DLLVM_PATH=path/to/llvm-source-root.")
+endif()
+
 
#===
 # Setup CMake Options
 
#===

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=256614&r1=256613&r2=256614&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Tue Dec 29 21:39:03 
2015
@@ -1,6 +1,4 @@
-
-
-macro(internal_find_llvm_parts)
+macro(find_llvm_parts)
 # Rely on llvm-config.
   set(CONFIG_OUTPUT)
   find_program(LLVM_CONFIG "llvm-config")
@@ -59,13 +57,16 @@ macro(internal_find_llvm_parts)
   list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
 
   set(LLVM_FOUND ON)
-endmacro(internal_find_llvm_parts)
+endmacro(find_llvm_parts)
 
 
-macro(internal_simulate_llvm_options)
-  # LLVM Options --
-  # Configure the LLVM CMake options expected by libc++.
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  set(LIBCXX_BUILT_STANDALONE 1)
+  message(STATUS "Configuring for standalone build.")
 
+  find_llvm_parts()
+
+  # LLVM Options --
   include(FindPythonInterp)
   if( NOT PYTHONINTERP_FOUND )
 message(WARNING "Failed to find python interpreter. "
@@ -131,29 +132,7 @@ macro(internal_simulate_llvm_options)
   MESSAGE(SEND_ERROR "Unable to determine platform")
 endif(UNIX)
   endif(WIN32)
-endmacro(internal_simulate_llvm_options)
-
-
-macro(handle_out_of_tree_llvm)
-  # This macro should not be called unless we are building out of tree.
-  # Enforce that.
-  if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-message(FATAL_ERROR "libc++ incorrectly configured for out-of-tree LLVM")
-  endif()
-
-  # Attempt to find an LLVM installation and source directory. Warn if they
-  # are not found.
-  internal_find_llvm_parts()
-  if (NOT LLVM_FOUND)
-message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
-"llvm-config not found and LLVM_PATH not defined.\n"
-"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
-"or -DLLVM_PATH=path/to/llvm-source-root.")
-  endif()
-
-  # Simulate the LLVM CMake options and variables provided by an in-tree LLVM.
-  internal_simulate_llvm_options()
 
-  # Additionally include the LLVM CMake functions if we can find the module.
+  # Add LLV

r256615 - [ptr-traits] Add #includes of headers rather than forward declarations

2015-12-29 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Dec 29 21:40:23 2015
New Revision: 256615

URL: http://llvm.org/viewvc/llvm-project?rev=256615&view=rev
Log:
[ptr-traits] Add #includes of headers rather than forward declarations
for types which are used as pointees in PointerUnions, PointerIntPairs,
and DenseMap pointer keys.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

I think this is the last patch for getting Clang clean here!!!

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=256615&r1=256614&r2=256615&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Dec 29 21:40:23 2015
@@ -28,6 +28,7 @@
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SanitizerBlacklist.h"

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256615&r1=256614&r2=256615&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 29 21:40:23 2015
@@ -21,6 +21,7 @@
 #include "clang/AST/Redeclarable.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Linkage.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
@@ -38,7 +39,6 @@ class FunctionTemplateDecl;
 class FunctionTemplateSpecializationInfo;
 class LabelStmt;
 class MemberSpecializationInfo;
-class Module;
 class NestedNameSpecifier;
 class ParmVarDecl;
 class Stmt;

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=256615&r1=256614&r2=256615&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Tue Dec 29 21:40:23 2015
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_MODULE_H
 #define LLVM_CLANG_BASIC_MODULE_H
 
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
@@ -35,9 +36,6 @@ namespace llvm {
 
 namespace clang {
   
-class DirectoryEntry;
-class FileEntry;
-class FileManager;
 class LangOptions;
 class TargetInfo;
 class IdentifierInfo;

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=256615&r1=256614&r2=256615&view=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Tue Dec 29 21:40:23 2015
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_SERIALIZATION_MODULE_H
 #define LLVM_CLANG_SERIALIZATION_MODULE_H
 
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ContinuousRangeMap.h"
@@ -32,7 +33,6 @@ template  class OnDiskIte
 
 namespace clang {
 
-class FileEntry;
 class DeclContext;
 class Module;
 

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h?rev=256615&r1=256614&r2=256615&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h 
Tue Dec 29 21:40:23 2015
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_FUNCTIONSUMMARY_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_FUNCTIONSUMMARY_H
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -22,7 +23,6 @@
 #includ

  1   2   >