summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/C++Tests/LLVM-Code-Syntax/lit.local.cfg29
-rw-r--r--utils/C++Tests/LLVM-Syntax/lit.local.cfg5
-rwxr-xr-xutils/TestUtils/deep-stack.py24
-rwxr-xr-xutils/TestUtils/pch-test.pl61
-rw-r--r--utils/clang-completion-mode.el38
5 files changed, 133 insertions, 24 deletions
diff --git a/utils/C++Tests/LLVM-Code-Syntax/lit.local.cfg b/utils/C++Tests/LLVM-Code-Syntax/lit.local.cfg
index 67bc5aed..c90f4f3 100644
--- a/utils/C++Tests/LLVM-Code-Syntax/lit.local.cfg
+++ b/utils/C++Tests/LLVM-Code-Syntax/lit.local.cfg
@@ -10,11 +10,36 @@ def getRoot(config):
root = getRoot(config)
# testFormat: The test format to use to interpret tests.
+target_obj_root = root.llvm_obj_root
cxxflags = ['-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS',
- '-Wno-sign-compare',
'-I%s/include' % root.llvm_src_root,
- '-I%s/include' % root.llvm_obj_root]
+ '-I%s/include' % root.llvm_obj_root,
+ '-I%s/lib/Target/Alpha' % root.llvm_src_root,
+ '-I%s/lib/Target/ARM' % root.llvm_src_root,
+ '-I%s/lib/Target/Blackfin' % root.llvm_src_root,
+ '-I%s/lib/Target/CellSPU' % root.llvm_src_root,
+ '-I%s/lib/Target/Mips' % root.llvm_src_root,
+ '-I%s/lib/Target/MSP430' % root.llvm_src_root,
+ '-I%s/lib/Target/PIC16' % root.llvm_src_root,
+ '-I%s/lib/Target/PowerPC' % root.llvm_src_root,
+ '-I%s/lib/Target/Sparc' % root.llvm_src_root,
+ '-I%s/lib/Target/SystemZ' % root.llvm_src_root,
+ '-I%s/lib/Target/X86' % root.llvm_src_root,
+ '-I%s/lib/Target/XCore' % root.llvm_src_root,
+ '-I%s/lib/Target/Alpha' % target_obj_root,
+ '-I%s/lib/Target/ARM' % target_obj_root,
+ '-I%s/lib/Target/Blackfin' % target_obj_root,
+ '-I%s/lib/Target/CellSPU' % target_obj_root,
+ '-I%s/lib/Target/Mips' % target_obj_root,
+ '-I%s/lib/Target/MSP430' % target_obj_root,
+ '-I%s/lib/Target/PIC16' % target_obj_root,
+ '-I%s/lib/Target/PowerPC' % target_obj_root,
+ '-I%s/lib/Target/Sparc' % target_obj_root,
+ '-I%s/lib/Target/SystemZ' % target_obj_root,
+ '-I%s/lib/Target/X86' % target_obj_root,
+ '-I%s/lib/Target/XCore' % target_obj_root];
+
config.test_format = \
lit.formats.OneCommandPerFileTest(command=[root.clang,
'-fsyntax-only'] + cxxflags,
diff --git a/utils/C++Tests/LLVM-Syntax/lit.local.cfg b/utils/C++Tests/LLVM-Syntax/lit.local.cfg
index b67bb90..cb0e566 100644
--- a/utils/C++Tests/LLVM-Syntax/lit.local.cfg
+++ b/utils/C++Tests/LLVM-Syntax/lit.local.cfg
@@ -12,14 +12,13 @@ root = getRoot(config)
# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.SyntaxCheckTest(compiler=root.clang,
dir='%s/include/llvm' % root.llvm_src_root,
- recursive=False,
+ recursive=True,
pattern='^(.*\\.h|[^.]*)$',
extra_cxx_args=['-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS',
- '-Wno-sign-compare',
'-Werror',
'-I%s/include' % root.llvm_src_root,
'-I%s/include' % root.llvm_obj_root])
config.excludes = ['AbstractTypeUser.h', 'DAGISelHeader.h',
- 'AIXDataTypesFix.h', 'LinkAllPasses.h', 'Solaris.h']
+ 'AIXDataTypesFix.h', 'Solaris.h']
diff --git a/utils/TestUtils/deep-stack.py b/utils/TestUtils/deep-stack.py
new file mode 100755
index 0000000..1750a5f
--- /dev/null
+++ b/utils/TestUtils/deep-stack.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+def pcall(f, N):
+ if N == 0:
+ print >>f, ' f(0)'
+ return
+
+ print >>f, ' f('
+ pcall(f, N - 1)
+ print >>f, ' )'
+
+def main():
+ f = open('t.c','w')
+ print >>f, 'int f(int n) { return n; }'
+ print >>f, 'int t() {'
+ print >>f, ' return'
+ pcall(f, 10000)
+ print >>f, ' ;'
+ print >>f, '}'
+
+if __name__ == "__main__":
+ import sys
+ sys.setrecursionlimit(100000)
+ main()
diff --git a/utils/TestUtils/pch-test.pl b/utils/TestUtils/pch-test.pl
new file mode 100755
index 0000000..e097c5c
--- /dev/null
+++ b/utils/TestUtils/pch-test.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl -w
+
+# This tiny little script, which should be run from the clang
+# directory (with clang in your patch), tries to take each
+# compilable Clang test and build a PCH file from that test, then read
+# and dump the contents of the PCH file just created.
+use POSIX;
+
+$exitcode = 0;
+sub testfiles($$) {
+ my $suffix = shift;
+ my $language = shift;
+ my $passed = 0;
+ my $failed = 0;
+ my $skipped = 0;
+
+ @files = `ls test/*/*.$suffix`;
+ foreach $file (@files) {
+ chomp($file);
+ my $code = system("clang- -fsyntax-only -x $language $file > /dev/null 2>&1");
+ if ($code == 0) {
+ print(".");
+ $code = system("clang -cc1 -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
+ if ($code == 0) {
+ $code = system("clang -cc1 -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
+ if ($code == 0) {
+ $passed++;
+ } elsif (($code & 0xFF) == SIGINT) {
+ exit($exitcode);
+ } else {
+ print("\n---Failed to dump AST file for \"$file\"---\n");
+ $exitcode = 1;
+ $failed++;
+ }
+ unlink "$file.pch";
+ } elsif (($code & 0xFF) == SIGINT) {
+ exit($exitcode);
+ } else {
+ print("\n---Failed to build PCH file for \"$file\"---\n");
+ $exitcode = 1;
+ $failed++;
+ }
+ } elsif (($code & 0xFF) == SIGINT) {
+ exit($exitcode);
+ } else {
+ print("x");
+ $skipped++;
+ }
+ }
+
+ print("\n\n$passed tests passed\n");
+ print("$failed tests failed\n");
+ print("$skipped tests skipped ('x')\n")
+}
+
+printf("-----Testing precompiled headers for C-----\n");
+testfiles("c", "c");
+printf("\n-----Testing precompiled headers for Objective-C-----\n");
+testfiles("m", "objective-c");
+print("\n");
+exit($exitcode);
diff --git a/utils/clang-completion-mode.el b/utils/clang-completion-mode.el
index 690fcda..4164eac 100644
--- a/utils/clang-completion-mode.el
+++ b/utils/clang-completion-mode.el
@@ -15,7 +15,7 @@
;; completion based on Clang. It needs your help to make it better!
;;
;; To use the Clang code completion mode, first make sure that the
-;; "clang-cc" variable below refers to the "clang-cc" executable,
+;; "clang" variable below refers to the "clang" executable,
;; which is typically installed in libexec/. Then, place
;; clang-completion-mode.el somewhere in your Emacs load path. You can
;; add a new load path to Emacs by adding some like the following to
@@ -40,21 +40,20 @@
;; file up to the point where the cursor is located. Therefore, Clang
;; needs all of the various compilation flags (include paths, dialect
;; options, etc.) to provide code-completion results. Currently, these
-;; need to be placed into the clang-cc-flags variable in a format
-;; acceptable to clang-cc. This is a hack: patches are welcome to
+;; need to be placed into the clang-flags variable in a format
+;; acceptable to clang. This is a hack: patches are welcome to
;; improve the interface between this Emacs mode and Clang!
;;
;;; Code:
-;;; The clang-cc executable
-(defcustom clang-cc "clang-cc"
- "The location of the clang-cc executable of the Clang compiler.
-This executable is typically installed into the libexec subdirectory."
+;;; The clang executable
+(defcustom clang "clang"
+ "The location of the Clang compiler executable"
:type 'file
:group 'clang-completion-mode)
-;;; Extra compilation flags to pass to clang-cc.
-(defcustom clang-cc-flags ""
+;;; Extra compilation flags to pass to clang.
+(defcustom clang-flags ""
"Extra flags to pass to the Clang executable.
This variable will typically contain include paths, e.g., -I~/MyProject."
:type 'string
@@ -69,7 +68,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
;;; The current completion buffer
(setq clang-completion-buffer nil)
-(setq clang-cc-result-string "")
+(setq clang-result-string "")
;;; Compute the current line in the buffer
(defun current-line ()
@@ -89,7 +88,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
;; produced. We store all of the results in a string, then the
;; sentinel processes the entire string at once.
(defun clang-completion-stash-filter (proc string)
- (setq clang-cc-result-string (concat clang-cc-result-string string)))
+ (setq clang-result-string (concat clang-result-string string)))
;; Filter the given list based on a predicate.
(defun filter (condp lst)
@@ -102,7 +101,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(string-match (concat "COMPLETION: " clang-completion-substring) line)))
(defun clang-completion-display (buffer)
- (let* ((all-lines (split-string clang-cc-result-string "\n"))
+ (let* ((all-lines (split-string clang-result-string "\n"))
(completion-lines (filter 'is-completion-line all-lines)))
(if (consp completion-lines)
(progn
@@ -125,7 +124,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
;; contents of the code-completion buffer with the new code-completion results
;; and ensures that the buffer is visible.
(defun clang-completion-sentinel (proc event)
- (let* ((all-lines (split-string clang-cc-result-string "\n"))
+ (let* ((all-lines (split-string clang-result-string "\n"))
(completion-lines (filter 'is-completion-line all-lines)))
(if (consp completion-lines)
(progn
@@ -145,8 +144,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
))))
(defun clang-complete ()
- (let ((ccstring (concat "-code-completion-at="
- (buffer-file-name)
+ (let ((ccstring (concat (buffer-file-name)
":"
(number-to-string (+ 1 (current-line)))
":"
@@ -161,16 +159,18 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(delete-process cc-proc)))
(setq clang-completion-substring "")
- (setq clang-cc-result-string "")
+ (setq clang-result-string "")
(setq clang-completion-buffer cc-buffer-name)
(let ((cc-proc
(if (equal clang-completion-prefix-header "")
(start-process "Clang Code-Completion" cc-buffer-name
- clang-cc "-fsyntax-only" ccstring
+ clang "-cc1" "-fsyntax-only"
+ "-code-completion-at" ccstring
(buffer-file-name))
(start-process "Clang Code-Completion" cc-buffer-name
- clang-cc "-fsyntax-only" ccstring
+ clang "-cc1" "-fsyntax-only"
+ "-code-completion-at" ccstring
"-include-pch"
(concat clang-completion-prefix-header ".pch")
(buffer-file-name)))))
@@ -252,6 +252,6 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(define-minor-mode clang-completion-mode
"Clang code-completion mode"
nil
- " Clang-CC"
+ " Clang"
clang-completion-mode-map)
OpenPOWER on IntegriCloud