]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Minor cleanups
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 1 Jan 2013 17:03:46 +0000 (18:03 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 1 Jan 2013 17:03:46 +0000 (18:03 +0100)
ccache.c
test.sh

index efc97fdd25049a1363fcaae0488101f40862cca3..87419033de4a71e91a3e944e1312fbee2979a0b8 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2,7 +2,7 @@
  * ccache -- a fast C/C++ compiler cache
  *
  * Copyright (C) 2002-2007 Andrew Tridgell
- * Copyright (C) 2009-2012 Joel Rosdahl
+ * Copyright (C) 2009-2013 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -562,10 +562,8 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
        hash_buffer(hash, p, (end - p));
        free(data);
 
-       /*
-        * Explicitly check the .gch/.pch/.pth file, Clang does not include any mention of
-        * it in the preprocessed output.
-        */
+       /* Explicitly check the .gch/.pch/.pth file, Clang does not include any
+        * mention of it in the preprocessed output. */
        if (included_pch_file) {
                char *path = x_strdup(included_pch_file);
                path = make_relative_path(path);
@@ -1629,8 +1627,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
 
                if (str_eq(argv[i], "-fpch-preprocess")
-                         || str_eq(argv[i], "-emit-pch")
-                         || str_eq(argv[i], "-emit-pth")) {
+                   || str_eq(argv[i], "-emit-pch")
+                   || str_eq(argv[i], "-emit-pth")) {
                        found_fpch_preprocess = true;
                }
 
@@ -1926,8 +1924,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
 
                        /* Try to be smart about detecting precompiled headers */
-                       if (str_eq(argv[i], "-include-pch") ||
-                                 str_eq(argv[i], "-include-pth")) {
+                       if (str_eq(argv[i], "-include-pch")
+                           || str_eq(argv[i], "-include-pth")) {
                                if (stat(argv[i+1], &st) == 0) {
                                        cc_log("Detected use of precompiled header: %s", argv[i+1]);
                                        found_pch = true;
@@ -1945,8 +1943,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                                cc_log("Detected use of precompiled header: %s", pchpath);
                                                found_pch = true;
                                                pch_file = x_strdup(pchpath);
-                                       }
-                                       else {
+                                       } else {
                                                /* clang may use pretokenized headers */
                                                char *pthpath = format("%s.pth", argv[i+1]);
                                                if (stat(pthpath, &st) == 0) {
diff --git a/test.sh b/test.sh
index 1c3ddc21d93d902c58fbe91452d5b322d69e7e0a..4209edf846206afc54d6f819663da093f45da36c 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -3,7 +3,7 @@
 # A simple test suite for ccache.
 #
 # Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2012 Joel Rosdahl
+# Copyright (C) 2009-2013 Joel Rosdahl
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -1904,7 +1904,6 @@ int main()
 }
 EOF
 
-
     if $COMPILER $SYSROOT -fpch-preprocess pch.h 2>/dev/null && [ -f pch.h.gch ] && $COMPILER $SYSROOT pch.c -o pch; then
         rm pch.h.gch
     else
@@ -1912,24 +1911,22 @@ EOF
         return
     fi
 
-    # clang and gcc handle precompiled headers similarly, but gcc
-    # is much more forgiving with precompiled headers. Both gcc and clang keep
-    # an absolute path reference to original file that created except that
-    # clang uses that reference to validate the pch and gcc ignores the reference.
-    # Also, clang has an additional feature: pre-tokenized headers. For these
-    # reasons clang should be tested separately than gcc.
-    # clang can only use pch or pth headers on the command line and not as an #include
-    # statement inside a source file
+    # clang and gcc handle precompiled headers similarly, but gcc is much more
+    # forgiving with precompiled headers. Both gcc and clang keep an absolute
+    # path reference to the original file except that clang uses that reference
+    # to validate the pch and gcc ignores the reference. Also, clang has an
+    # additional feature: pre-tokenized headers. For these reasons clang should
+    # be tested separately than gcc. clang can only use pch or pth headers on
+    # the command line and not as an #include statement inside a source file.
 
     if [ $COMPILER_TYPE_CLANG -eq 1 ]; then
         clang_pch_suite
     else
         gcc_pch_suite
-    fi    
+    fi
 }
 
 gcc_pch_suite() {
-
     ##################################################################
     # Tests for creating a .gch.
 
@@ -2053,8 +2050,6 @@ gcc_pch_suite() {
 }
 
 clang_pch_suite() {
-
-
     ##################################################################
     # Tests for creating a .gch.
 
@@ -2109,7 +2104,7 @@ clang_pch_suite() {
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER $SYSROOT -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
-    checkstat 'cache miss' 1    
+    checkstat 'cache miss' 1
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER $SYSROOT -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
@@ -2147,7 +2142,6 @@ clang_pch_suite() {
     checkstat 'cache miss' 2
 
     rm pch.h.gch
-    
 
     ##################################################################
     # Tests for creating a .pth.
@@ -2167,7 +2161,7 @@ clang_pch_suite() {
     checkstat 'cache miss' 1
     if [ ! -f pch.h.pth ]; then
         test_failed "pch.h.pth missing"
-    fi    
+    fi
 
     ##################################################################
     # Tests for using a .pth.
@@ -2188,7 +2182,7 @@ clang_pch_suite() {
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER $SYSROOT -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
-    checkstat 'cache miss' 1    
+    checkstat 'cache miss' 1
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER $SYSROOT -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
@@ -2226,7 +2220,6 @@ clang_pch_suite() {
     checkstat 'cache miss' 2
 
     rm pch.h.pth
-
 }
 
 upgrade_suite() {
@@ -2340,21 +2333,21 @@ touch $CCACHE_CONFIGPATH
 
 
 if [ $HOST_OS_APPLE -eq 1 ]; then
-    # grab the developer directory from the environment if not try xcode-select
+    # Grab the developer directory from the environment or try xcode-select
     if [ "$XCODE_DEVELOPER_DIR" = "" ]; then
-        XCODE_DEVELOPER_DIR=$(xcode-select --print-path)
+      XCODE_DEVELOPER_DIR=`xcode-select --print-path`
       if [ "$XCODE_DEVELOPER_DIR" = "" ]; then
-        echo "Error: XCODE_DEVELOPER_DIR environment variable not set and xcode-select path not set."
+        echo "Error: XCODE_DEVELOPER_DIR environment variable not set and xcode-select path not set"
         exit 1
       fi
     fi
 
-    # choose the latest SDK if a sdk root is not set
+    # Choose the latest SDK if an SDK root is not set
     MAC_PLATFORM_DIR=$XCODE_DEVELOPER_DIR/Platforms/MacOSX.platform
     if [ "$SDKROOT" = "" ]; then
         SDKROOT="`eval ls -f -1 -d \"$MAC_PLATFORM_DIR/Developer/SDKs/\"*.sdk | tail -1`"
         if [ "$SDKROOT" = "" ]; then
-            echo "Error: Cannot find a valid sdk root directory"
+            echo "Error: Cannot find a valid SDK root directory"
             exit 1
         fi
     fi
@@ -2408,7 +2401,7 @@ if [ -z "$suites" ]; then
 fi
 
 for suite in $suites; do
-   run_suite $suite
+    run_suite $suite
 done
 
 # ---------------------------------------